diff --git a/Alignment/MillePedeAlignmentAlgorithm/templates/universalConfigTemplate.py b/Alignment/MillePedeAlignmentAlgorithm/templates/universalConfigTemplate.py index 45a5848cb254f..acf65ccf1c341 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/templates/universalConfigTemplate.py +++ b/Alignment/MillePedeAlignmentAlgorithm/templates/universalConfigTemplate.py @@ -267,6 +267,10 @@ # # a list of possible options is documented here: # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd # # +# # if you need to request a larger stack size for individual threads when +# # running pede, you can do this with this setting: +# # process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; pede" +# # # # you can change or drop pede options as follows: # # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper diff --git a/Alignment/OfflineValidation/bin/BuildFile.xml b/Alignment/OfflineValidation/bin/BuildFile.xml new file mode 100644 index 0000000000000..13ac80ece0586 --- /dev/null +++ b/Alignment/OfflineValidation/bin/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Alignment/OfflineValidation/bin/DMRtrends.cc b/Alignment/OfflineValidation/bin/DMRtrends.cc new file mode 100644 index 0000000000000..4226179dbefb0 --- /dev/null +++ b/Alignment/OfflineValidation/bin/DMRtrends.cc @@ -0,0 +1,753 @@ +#include +#include +#include +#include +#include +#include +#include +#include "TPad.h" +#include "TCanvas.h" +#include "TGraph.h" +#include "TGraphErrors.h" +#include "TMultiGraph.h" +#include "TH1.h" +#include "THStack.h" +#include "TROOT.h" +#include "TFile.h" +#include "TColor.h" +#include "TLegend.h" +#include "TLegendEntry.h" +#include "TMath.h" +#include "TRegexp.h" +#include "TPaveLabel.h" +#include "TPaveText.h" +#include "TStyle.h" +#include "TLine.h" + +using namespace std; +namespace fs = std::experimental::filesystem; + +/*! + * \def Dummy value in case a DMR would fail for instance + */ +#define DUMMY -999. +/*! + * \def Scale factor value to have luminosity expressed in fb^-1 + */ +#define lumiFactor 1000. +/*! + * \def Scale factor value to have mean and sigmas expressed in micrometers. + */ +#define DMRFactor 10000. + +/*! \struct Point + * \brief Structure Point + * Contains parameters of Gaussian fits to DMRs + * + * @param run: run number (IOV boundary) + * @param mu: mu/mean from Gaussian fit to DMR + * @param sigma: sigma/standard deviation from Gaussian fit to DMR + * @param muplus: mu/mean for the inward pointing modules + * @param muminus: mu/mean for outward pointing modules + * @param sigmaplus: sigma/standard for inward pointing modules + * @param sigmaminus: //!< sigma/standard for outward pointing modules + */ +struct Point { + float run, mu, sigma, muplus, muminus, sigmaplus, sigmaminus; + + /*! \fn Point + * \brief Constructor of structure Point, initialising all members one by one + */ + Point (float Run = DUMMY, float y1 = DUMMY,float y2 = DUMMY, float y3 = DUMMY, float y4 = DUMMY, float y5 = DUMMY, float y6 = DUMMY) : + run(Run), mu(y1), sigma(y2), muplus(y3), muminus(y5), sigmaplus(y4), sigmaminus(y6) + {} + + /*! \fn Point + * \brief Constructor of structure Point, initialising all members from DMRs directly (with split) + */ + Point (float Run, TH1 * histo, TH1 * histoplus, TH1 * histominus) : + Point(Run, histo->GetMean(), histo->GetMeanError(), + histoplus->GetMean(), histoplus->GetMeanError(), + histominus->GetMean(), histominus->GetMeanError()) + {} + + /*! \fn Point + * \brief Constructor of structure Point, initialising all members from DMRs directly (without split) + */ + Point (float Run, TH1 * histo) : + Point(Run, histo->GetMean(), histo->GetMeanError()) + {} + + Point& operator=(const Point &p){ run = p.run; mu = p.mu; muplus = p.muplus; muminus = p.muminus; sigma = p.sigma; sigmaplus = p.sigmaplus; sigmaminus = p.sigmaminus; return *this;} + + float GetRun () const { return run ; } + float GetMu () const { return DMRFactor*mu ; } + float GetMuPlus () const { return DMRFactor*muplus ; } + float GetMuMinus () const { return DMRFactor*muminus ; } + float GetSigma () const { return DMRFactor*sigma ; } + float GetSigmaPlus () const { return DMRFactor*sigmaplus ; } + float GetSigmaMinus () const { return DMRFactor*sigmaminus; } + float GetDeltaMu () const { if(muplus==DUMMY&&muminus==DUMMY) return DUMMY; + else return DMRFactor*(muplus - muminus); } + float GetSigmaDeltaMu () const { if(sigmaplus==DUMMY&&sigmaminus==DUMMY) return DUMMY; + else return DMRFactor*hypot(sigmaplus,sigmaminus); }; +}; + + +///************************** +///* Function declaration * +///************************** + +TString getName (TString structure, int layer, TString geometry); +TH1F* ConvertToHist(TGraphErrors *g); +vector runlistfromlumifile(TString Year="2018"); +bool checkrunlist(vector runs, vector IOVlist={}, TString Year="2018"); +TString lumifileperyear(TString Year="2018", string RunOrIOV="IOV"); +void scalebylumi(TGraphErrors *g, TString Year="2018", double min=0.); +double getintegratedlumiuptorun(int run, TString Year="2018", double min=0.); +void PixelUpdateLines(TCanvas *c, TString Year="2018", bool showlumi=false, vectorpixelupdateruns={314881, 316758, 317527, 318228, 320377}); +void PlotDMRTrends(vectorlabels={"MB"}, TString Year="2018", string myValidation="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/acardini/DMRs/", vector geometries={"GT","SG", "MP pix LBL","PIX HLS+ML STR fix"}, vector colours={kBlue, kRed, kGreen, kCyan}, TString outputdir="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/alignmentObjects/acardini/DMRsTrends/", bool pixelupdate=false, vector pixelupdateruns={314881, 316758, 317527, 318228, 320377}, bool showlumi=false); +void compileDMRTrends(vector IOVlist, vectorlabels={"MB"}, TString Year="2018", string myValidation="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/acardini/DMRs/", vector geometries={"GT","SG", "MP pix LBL","PIX HLS+ML STR fix"} ,bool showlumi=false, bool FORCE=false); +void DMRtrends(vector IOVlist, vectorlabels={"MB"}, TString Year="2018", string myValidation="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/acardini/DMRs/", vector geometries={"GT","SG", "MP pix LBL","PIX HLS+ML STR fix"}, vector colours={kBlue, kRed, kGreen, kCyan}, TString outputdir="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/alignmentObjects/acardini/DMRsTrends/", bool pixelupdate=false, vector pixelupdateruns={314881, 316758, 317527, 318228, 320377}, bool showlumi=false, bool FORCE=false); + +/*! \class Geometry + * \brief Class Geometry + * Contains vector for fit parameters (mean, sigma, etc.) obtained from multiple IOVs + * See Structure Point for description of the parameters. + */ + +class Geometry { + public: + vector points; + private: + //template vector GetQuantity (T (Point::*getter)() const) const { + vector GetQuantity (float (Point::*getter)() const) const { + vector v; + for (Point point: points) { + float value = (point.*getter)(); + v.push_back(value); + } + return v; + } + public: + TString title; + Geometry() : title ("") {} + Geometry(TString Title) : title(Title) {} + Geometry& operator=(const Geometry &geom){ title = geom.title; points = geom.points; return *this;} + void SetTitle(TString Title){ title = Title;} + TString GetTitle() { return title; } + vector Run () const { return GetQuantity( &Point::GetRun ); } + vector Mu () const { return GetQuantity( &Point::GetMu ); } + vector MuPlus () const { return GetQuantity( &Point::GetMuPlus ); } + vector MuMinus () const { return GetQuantity( &Point::GetMuMinus ); } + vector Sigma () const { return GetQuantity( &Point::GetSigma ); } + vector SigmaPlus () const { return GetQuantity( &Point::GetSigmaPlus ); } + vector SigmaMinus () const { return GetQuantity( &Point::GetSigmaMinus ); } + vector DeltaMu () const { return GetQuantity( &Point::GetDeltaMu ); } + vector SigmaDeltaMu () const { return GetQuantity( &Point::GetSigmaDeltaMu); } + //vector Graph (string variable) const { + // }; +}; + +/// DEPRECATED +//struct Layer { +// map geometries; +//}; +// +//struct HLS { +// vector layers; +// map geometries; +//}; + + +/*! \fn getName + * \brief Function used to get a string containing information on the high level structure, the layer/disc and the geometry. + */ + +TString getName (TString structure, int layer, TString geometry){ + geometry.ReplaceAll(" ","_"); + TString name=geometry+"_"+structure; + if(layer!=0){ + if(structure=="TID"||structure=="TEC")name+="_disc"; + else name+="_layer"; + name+=layer; + } + + return name; +}; +/// TO DO: once the information on the luminosity is passed through the root files this method needs to be changed +/*! \fn lumifileperyear + * \brief Function to retrieve the file with luminosity per run/IOV + */ + +TString lumifileperyear(TString Year, string RunOrIOV){ + TString LumiFile=getenv("CMSSW_BASE"); LumiFile +="/src/Alignment/OfflineValidation/data/lumiper"; + if(RunOrIOV!="run"&&RunOrIOV!="IOV") cout << "ERROR: Please specify \"run\" or \"IOV\" to retrieve the luminosity run by run or for each IOV"< runlistfromlumifile(TString Year){ + TGraph * scale = new TGraph((lumifileperyear(Year,"run")).Data()); + double *xscale = scale->GetX(); + size_t N = scale->GetN(); + vector runs; + for(size_t i=0;i runs,vector IOVlist, TString Year){ + vector runlist = runlistfromlumifile(Year); + vector missingruns; //runs for which the luminosity is not found + vector lostruns; //IOVs for which the DMR were not found + bool problemfound=false; + for(int run : runs){ + if(find(runlist.begin(),runlist.end(),run)==runlist.end()){ + problemfound=true; + missingruns.push_back(run); + } + } + if(!IOVlist.empty()) for(int IOV : IOVlist){ + if(find(runs.begin(),runs.end(),IOV)==runs.end()){ + problemfound=true; + lostruns.push_back(IOV); + } + } + std::sort(missingruns.begin(),missingruns.end()); + if(problemfound){ + if(!lostruns.empty()){ + cout << "WARNING: some IOVs where not found among the list of available DMRs" << endl << "List of missing IOVs:" << endl; + for (int lostrun : lostruns) cout << to_string(lostrun) << " "; + cout << endl; + } + if(!missingruns.empty()){ + cout << "WARNING: some runs are missing in the run/luminosity txt file" << endl << "List of missing runs:" << endl; + for (int missingrun : missingruns) cout << to_string(missingrun) << " "; + cout << endl; + } + } + return problemfound; + +} + +/*! \fn DMRtrends + * \brief Create and plot the DMR trends. + */ + +void DMRtrends(vector IOVlist,vector labels, TString Year, string myValidation, vector geometries, vector colours, TString outputdir, bool pixelupdate, vector pixelupdateruns, bool showlumi, bool FORCE){ + compileDMRTrends(IOVlist, labels, Year, myValidation, geometries, showlumi, FORCE); + cout<< "Begin plotting"< IOVlist, vector labels, TString Year, string myValidation, vector geometries, bool showlumi, bool FORCE){ + gROOT->SetBatch(); + vectorRunNumbers; + vector filenames; + TRegexp regexp("[0-9][0-9][0-9][0-9][0-9][0-9]"); + for (const auto & entry : fs::recursive_directory_iterator(myValidation)){ + bool found_all_labels = true; + for(string label : labels){ + if(entry.path().string().find(label)==std::string::npos) found_all_labels = false; + } + if ((entry.path().string().find("ExtendedOfflineValidation_Images/OfflineValidationSummary.root")!=std::string::npos)&&found_all_labels){ + if(fs::is_empty(entry.path())) cout << "ERROR: Empty file " << entry.path() << endl; + else{ + TString filename(entry.path().string()); + filenames.push_back(filename); + TString runstring(filename(regexp)); + if(runstring.IsFloat()){ + int runN=runstring.Atoi(); + RunNumbers.push_back(runN); + } + } + } + } + if(checkrunlist(RunNumbers,IOVlist,Year)&&showlumi&&!FORCE){ + cout << "Please fix the run/luminosities file!" << endl; + exit(EXIT_FAILURE); + } + + vector structures { "BPIX", "BPIX_y", "FPIX", "FPIX_y", "TIB", "TID", "TOB", "TEC"}; + + const map nlayers{ {"BPIX", 4}, {"FPIX", 3}, {"TIB", 4}, {"TID", 3}, {"TOB", 6}, {"TEC", 9} }; + + + map,TString>,Geometry> mappoints; // pair = (structure, layer), geometry + + std::sort(filenames.begin(),filenames.end());//order the files in alphabetical order + for (TString filename: filenames){ + int runN; + TString runstring(filename(regexp)); + if(runstring.IsFloat()){ + runN=runstring.Atoi(); + } + else{ + cout << "ERROR: run number not retrieved for file " << filename << endl; + continue; + } + + TFile * f = new TFile(filename, "READ"); + + for (TString& structure: structures) { + TString structname = structure; + structname.ReplaceAll("_y", ""); + size_t layersnumber=nlayers.at(structname); + for (size_t layer=0; layer<=layersnumber;layer++){ + for (string geometry: geometries) { + TString name = getName(structure, layer, geometry); + TH1F *histo = dynamic_cast(f->Get( name)); + //Geometry *geom =nullptr; + Point * point = nullptr; + // Three possibilities: + // - All histograms are produced correctly + // - Only the non-split histograms are produced + // - No histogram is produced correctly + // FORCE means that the Point is not added to the points collection in the chosen geometry for that structure + // If FORCE is not enabled a default value for the Point is used (-9999) which will appear in the plots + if(!histo){ + cout << "Run" << runN << " Histogram: " << name << " not found" << endl; + if(FORCE)continue; + point= new Point(runN); + }else if(structure!="TID"&&structure!="TEC"){ + TH1F *histoplus = dynamic_cast(f->Get((name+"_plus"))); + TH1F *histominus = dynamic_cast(f->Get((name+"_minus"))); + if(!histoplus||!histominus){ + cout << "Run" << runN << " Histogram: " << name << " plus or minus not found" << endl; + if(FORCE)continue; + point= new Point(runN, histo); + }else point= new Point(runN, histo, histoplus, histominus); + + }else point= new Point(runN, histo); + mappoints[make_pair(make_pair(structure,layer),geometry)].points.push_back(*point); + } + } + } + f->Close(); + } + TString outname=myValidation+"DMRtrends"; + for(TString label : labels){outname+="_"; outname+=label;} + outname+=".root"; + TFile * fout = TFile::Open(outname, "RECREATE"); + for (TString& structure: structures) { + TString structname = structure; + structname.ReplaceAll("_y", ""); + size_t layersnumber=nlayers.at(structname); + for (size_t layer=0; layer<=layersnumber;layer++){ + for (string geometry : geometries) { + TString name = getName(structure, layer, geometry); + Geometry geom = mappoints[make_pair(make_pair(structure,layer),geometry)]; + using Trend = vector (Geometry::*)() const; + vector trends {&Geometry::Mu, &Geometry::Sigma, &Geometry::MuPlus, &Geometry::SigmaPlus, + &Geometry::MuMinus, &Geometry::SigmaMinus, &Geometry::DeltaMu, &Geometry::SigmaDeltaMu }; + vector variables {"mu", "sigma", "muplus", "sigmaplus", "muminus", "sigmaminus", "deltamu", "sigmadeltamu" }; + vector runs = geom.Run(); + size_t n = runs.size(); + vector emptyvec; + for(size_t i=0; i < runs.size(); i++)emptyvec.push_back(0.); + for(size_t iVar=0; iVar < variables.size(); iVar++){ + Trend trend=trends.at(iVar); + TGraphErrors *g = new TGraphErrors(n, runs.data(), (geom.*trend)().data(), emptyvec.data(), emptyvec.data()); + g->SetTitle(geometry.c_str()); + g->Write(name+"_"+variables.at(iVar)); + } + vector> trendspair {make_pair(&Geometry::Mu, &Geometry::Sigma), make_pair(&Geometry::MuPlus, &Geometry::SigmaPlus), + make_pair(&Geometry::MuMinus, &Geometry::SigmaMinus), make_pair(&Geometry::DeltaMu, &Geometry::SigmaDeltaMu) }; + vector> variablepairs {make_pair("mu", "sigma"), make_pair("muplus", "sigmaplus"), make_pair("muminus", "sigmaminus"), make_pair("deltamu", "sigmadeltamu") }; + for(size_t iVar=0; iVar < variablepairs.size(); iVar++){ + Trend meantrend=trendspair.at(iVar).first; + Trend sigmatrend=trendspair.at(iVar).second; + TGraphErrors *g = new TGraphErrors(n, runs.data(), (geom.*meantrend)().data(), emptyvec.data(), (geom.*sigmatrend)().data()); + g->SetTitle(geometry.c_str()); + TString graphname = name+"_"+variablepairs.at(iVar).first; + graphname+=variablepairs.at(iVar).second; + g->Write(graphname); + } + } + } + } + fout->Close(); + +} + +/*! \fn PixelUpdateLines + * \brief Adds to the canvas vertical lines corresponding to the pixelupdateruns + */ +void PixelUpdateLines(TCanvas *c, TString Year, bool showlumi, vectorpixelupdateruns){ + vector labels; + double lastlumi=0.; + c->cd(); + size_t index = 0; + for(int pixelupdaterun : pixelupdateruns){ + double lumi=0.; + if(showlumi)lumi=getintegratedlumiuptorun(pixelupdaterun,Year); //The vertical line needs to be drawn at the beginning of the run where the pixel update was implemented, thus only the integrated luminosity up to that run is required. + else lumi=pixelupdaterun; + TLine *line = new TLine (lumi,c->GetUymin(),lumi,c->GetUymax()); + line->SetLineColor(kBlue); + line->SetLineStyle(9); + line->Draw(); + //Due to the way the coordinates within the Canvas are set, the following steps are required to draw the TPaveText: + // Compute the gPad coordinates in TRUE normalized space (NDC) + int ix1; + int ix2; + int iw = gPad->GetWw(); + int ih = gPad->GetWh(); + double x1p,y1p,x2p,y2p; + gPad->GetPadPar(x1p,y1p,x2p,y2p); + ix1 = (Int_t)(iw*x1p); + ix2 = (Int_t)(iw*x2p); + double wndc = TMath::Min(1.,(double)iw/(double)ih); + double rw = wndc/(double)iw; + double x1ndc = (double)ix1*rw; + double x2ndc = (double)ix2*rw; + // Ratios to convert user space in TRUE normalized space (NDC) + double rx1,ry1,rx2,ry2; + gPad->GetRange(rx1,ry1,rx2,ry2); + double rx = (x2ndc-x1ndc)/(rx2-rx1); + double _sx; + // Left limit of the TPaveText + _sx = rx*(lumi-rx1)+x1ndc; + // To avoid an overlap between the TPaveText a vertical shift is done when the IOVs are too close + if( _sx < lastlumi ){ + index++; + }else index=0; + TPaveText *box= new TPaveText(_sx+0.0015,0.86-index*0.04,_sx+0.035,0.89-index*0.04,"blNDC"); + box->SetFillColor(10); + box->SetBorderSize(1); + box->SetLineColor(kBlack); + TText *textRun = box->AddText(Form("%i",int(pixelupdaterun))); + textRun->SetTextSize(0.025); + labels.push_back(box); + lastlumi=_sx+0.035; + } + //Drawing in a separate loop to ensure that the labels are drawn on top of the lines + for(auto label: labels){ + label->Draw("same"); + } + c->Update(); +} + +/*! \fn getintegratedlumiuptorun + * \brief Returns the integrated luminosity up to the run of interest + */ + +double getintegratedlumiuptorun(int run, TString Year, double min){ + TGraph * scale = new TGraph((lumifileperyear(Year,"run")).Data()); + int Nscale=scale->GetN(); + double *xscale=scale->GetX(); + double *yscale=scale->GetY(); + + + double lumi=min; + int index=-1; + for(int j=0;j=xscale[j]){ + index=j; + continue; + } + } + lumi=min; + for(int j=0;jGetN(); + vector x,y,xerr,yerr; + + TGraph * scale = new TGraph((lumifileperyear(Year,"IOV")).Data()); + size_t Nscale=scale->GetN(); + double *xscale=scale->GetX(); + double *yscale=scale->GetY(); + + size_t i=0; + while(iGetPoint(i,run,yvalue); + size_t index=-1; + for(size_t j=0;jxscale[j]) continue; + } + if(yscale[index]==0||index<0.){ + N=N-1; + g->RemovePoint(i); + }else{ + double xvalue=min; + for(size_t j=0;jGetErrorY(i)); + } + xerr.push_back(yscale[index]/(lumiFactor*2.)); + i=i+1; + } + + } + g->GetHistogram()->Delete(); + g->SetHistogram(nullptr); + for(size_t i=0;iSetPoint(i, x.at(i),y.at(i)); g->SetPointError(i, xerr.at(i),yerr.at(i));} + +} + +/*! \fn ConvertToHist + * \brief A TH1F is constructed using the points and the errors collected in the TGraphErrors + */ + +TH1F *ConvertToHist(TGraphErrors *g){ + size_t N=g->GetN(); + double* x=g->GetX(); + double* y=g->GetY(); + double* xerr=g->GetEX(); + vector bins; + bins.push_back(x[0]-xerr[0]); + for(size_t i=1;i (bins.back() + pow(10,-6))) bins.push_back(x[i-1]+xerr[i-1]); + if((x[i]-xerr[i]) > (bins.back() + pow(10,-6))) bins.push_back(x[i]-xerr[i]); + + } + bins.push_back(x[N-1]+xerr[N-1]); + TString histoname="histo_"; + histoname+=g->GetName(); + TH1F *histo = new TH1F(histoname,g->GetTitle(),bins.size()-1,bins.data()); + for(size_t i=0;iFill(x[i],y[i]); + histo->SetBinError(histo->FindBin(x[i]),pow(10,-6)); + } + return histo; +} + + +/*! \fn PlotDMRTrends + * \brief Plot the DMR trends. + */ + +void PlotDMRTrends(vector labels, TString Year, string myValidation, vector geometries, vector colours, TString outputdir, bool pixelupdate, vector pixelupdateruns, bool showlumi){ + gErrorIgnoreLevel = kWarning; + checkrunlist(pixelupdateruns,{},Year); + vector structures { "BPIX", "BPIX_y", "FPIX", "FPIX_y", "TIB", "TID", "TOB", "TEC"}; + + const map nlayers{ {"BPIX", 4}, {"FPIX", 3}, {"TIB", 4}, {"TID", 3}, {"TOB", 6}, {"TEC", 9} }; + + + TString filename=myValidation+"DMRtrends"; + for(TString label : labels){ filename+="_"; filename+=label;} + filename+=".root"; + TFile *in= new TFile(filename); + for (TString& structure: structures) { + TString structname = structure; + structname.ReplaceAll("_y", ""); + int layersnumber=nlayers.at(structname); + for (int layer=0; layer<=layersnumber;layer++){ + vector variables {"mu", "sigma", "muplus", "sigmaplus", "muminus", "sigmaminus", "deltamu", "sigmadeltamu", "musigma", "muplussigmaplus", "muminussigmaminus", "deltamusigmadeltamu"}; + vector YaxisNames { "#mu [#mum]", "#sigma_{#mu} [#mum]", "#mu outward [#mum]", "#sigma_{#mu outward} [#mum]", "#mu inward [#mum]", "#sigma_{#mu inward} [#mum]", "#Delta#mu [#mum]", "#sigma_{#Delta#mu} [#mum]", "#mu [#mum]", "#mu outward [#mum]", "#mu inward [#mum]", "#Delta#mu [#mum]",}; + //For debugging purposes we still might want to have a look at plots for a variable without errors, once ready for the PR those variables will be removed and the iterator will start from 0 + for(size_t i=8; i < variables.size(); i++){ + TString variable= variables.at(i); + TCanvas * c = new TCanvas("dummy","",2000,800); + vector::iterator colour = colours.begin(); + + TMultiGraph *mg = new TMultiGraph(structure,structure); + THStack *mh = new THStack(structure,structure); + size_t igeom=0; + for (string geometry: geometries) { + TString name = getName(structure, layer, geometry); + TGraphErrors *g = dynamic_cast (in->Get(name+"_"+variables.at(i))); + g->SetName(name+"_"+variables.at(i)); + if(i>=8){ + g->SetLineWidth(1); + g->SetLineColor(*colour); + g->SetFillColorAlpha(*colour,0.2); + } + vector> vectors; + //if(showlumi&&i<8)scalebylumi(dynamic_cast(g)); + if(showlumi)scalebylumi(g,Year); + g->SetLineColor(*colour); + g->SetMarkerColor(*colour); + TH1F *h = ConvertToHist(g); + h->SetLineColor(*colour); + h->SetMarkerColor(*colour); + h->SetMarkerSize(0); + h->SetLineWidth(1); + + if(i<8){ + mg->Add(g,"PL"); + mh->Add(h,"E"); + }else{ + mg->Add(g,"2"); + mh->Add(h,"E"); + } + ++colour; + ++igeom; + } + if(i<8){ + mg->Draw("a"); + }else{ + mg->Draw("a2"); + } + double max=6; + double min=-4; + double range=max-min; + if(((variable=="sigma"||variable=="sigmaplus"||variable=="sigmaminus"||variable=="sigmadeltamu")&&range>=2)){ + mg->SetMaximum(4); + mg->SetMinimum(-2); + }else{ + mg->SetMaximum(max+range*0.1); + mg->SetMinimum(min-range*0.3); + } + + char* Ytitle= (char *)YaxisNames.at(i).c_str(); + mg->GetYaxis()->SetTitle(Ytitle); + mg->GetXaxis()->SetTitle(showlumi ? "Integrated lumi [1/fb]" : "IOV number"); + mg->GetXaxis()->CenterTitle(true); + mg->GetYaxis()->CenterTitle(true); + mg->GetYaxis()->SetTitleOffset(.5); + mg->GetYaxis()->SetTitleSize(.05); + mg->GetXaxis()->SetTitleSize(.04); + if(showlumi) mg->GetXaxis()->SetLimits(0.,mg->GetXaxis()->GetXmax()); + gStyle->SetOptTitle(0); // TODO + gPad->SetTickx(); + gPad->SetTicky(); + //c->SetLeftMargin(0.11); + + c->Update(); + + //gStyle->SetLegendBorderSize(0); + gStyle->SetLegendTextSize(0.025); + + //TLegend *legend = c->BuildLegend(); + TLegend *legend = c->BuildLegend(0.3,0.15,0.3,0.15); + int Ngeom=geometries.size(); + legend->SetNColumns(Ngeom); + //legend->SetTextSize(0.05); + TString structtitle = structure; + if(layer!=0){ + if(structure=="TID"||structure=="TEC"||structure=="FPIX"||structure=="FPIX_y")structtitle+="_disc"; + else structtitle+="_layer"; + structtitle+=layer; + } + legend->SetHeader("#scale[1.2]{#bf{CMS} Work in progress}"); + //TLegendEntry *header = (TLegendEntry*)legend->GetListOfPrimitives()->First(); + //header->SetTextSize(.04); + legend->AddEntry((TObject*)nullptr,structtitle.Data(),"h"); + + //TLegendEntry *str = (TLegendEntry*)legend->GetListOfPrimitives()->Last(); + //str->SetTextSize(.03); + PixelUpdateLines(c, Year, showlumi, pixelupdateruns); + + legend->Draw(); + mh->Draw("nostack same"); + c->Update(); + TString structandlayer = getName(structure,layer,""); + TString printfile=outputdir; + for(TString label : labels){printfile+=label;printfile+="_";} + printfile+=variable+structandlayer; + c->SaveAs(printfile+".pdf"); + c->SaveAs(printfile+".eps"); + c->SaveAs(printfile+".png"); + c->Destructor(); + } + + } + + } + in->Close(); +} + +/*! \fn main + * \brief main function: if no arguments are specified a default list of arguments is used, otherwise a total of 9 arguments are required: + * @param IOVlist: string containing the list of IOVs separated by a "," + * @param labels: string containing labels that must be part of the input files + * @param Year: string containing the year of the studied runs (needed to retrieve the lumi-per-run file) + * @param pathtoDMRs: string containing the path to the directory where the DMRs are stored + * @param geometrieandcolours: string containing the list of geometries and colors in the following way name1:color1,name2:color2 etc. + * @param outputdirectory: string containing the output directory for the plots + * @param pixelupdatelist: string containing the list of pixelupdates separated by a "," + * @param showpixelupdate: boolean that if set to true will allow to plot vertical lines in the canvas corresponding to the pixel updates + * @param showlumi: boolean, if set to false the trends will be presented in function of the run (IOV) number, if set to true the luminosity is used on the x axis + * @param FORCE: //!< boolean, if set to true the plots will be made regardless of possible errors. + * Eventual errors while running the code will be ignored and just warnings will appear in the output. + */ + +int main (int argc, char * argv[]) { + if (argc == 1) { + + vectorIOVlist={290543, 296702, 296966, 297224, 297281, 297429, 297467, 297484, 297494, 297503, 297557, 297599, 297620, 297660, 297670, 298678, 298996, 299062, 299096, 299184, 299327, 299368, 299381, 299443, 299480, 299592, 299594, 299649, 300087, 300155, 300233, 300237, 300280, 300364, 300389, 300399, 300459, 300497, 300515, 300538, 300551, 300574, 300636, 300673, 300780, 300806, 300812, 301046, 301417, 302131, 302573, 302635, 303825, 303998, 304170, 304505, 304672, 305040, 305081};//UL17 + //vector pixelupdateruns {316758, 317527,317661,317664,318227, 320377};//2018 + vector pixelupdateruns {290543, 297281, 298653, 299443, 300389, 302131, 303790, 304911, 305898};//2017 + + cout << "WARNING: Running function with arguments specified in DMRtrends.cc" << endl << "If you want to specify the arguments from command line run the macro as follows:" << endl << "DMRtrends labels pathtoDMRs geometriesandcolourspairs outputdirectory showpixelupdate showlumi FORCE" << endl; + + //Example provided for a currently working set of parameters + DMRtrends(IOVlist,{"vUL17","MB"},"2017", "/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/results/acardini/DMRs/EOY17/", {"EOY17","full ML pixel + strip","SG-mp2607","mp2993"}, {kRed, kBlack, kBlue, kGreen}, "/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/data/commonValidation/alignmentObjects/acardini/DMRsTrends/", true, pixelupdateruns, true, true); + + + return 0; + } + else if (argc < 11) { + cout << "DMRtrends IOVlist labels Year pathtoDMRs geometriesandcolourspairs outputdirectory pixelupdatelist showpixelupdate showlumi FORCE" << endl; + + return 1; + } + + TString runlist = argv[1], + all_labels = argv[2], + Year = argv[3], + pathtoDMRs = argv[4], + geometrieandcolours = argv[5], //name1:title1:color1,name2:title2:color2,name3:title3:color3 + outputdirectory = argv[6], + pixelupdatelist = argv[7]; + bool showpixelupdate = argv[8], + showlumi = argv[9], + FORCE = argv[10]; + TObjArray *labelarray = all_labels.Tokenize(","); + vector labels; + for(int i=0; i < labelarray->GetEntries(); i++)labels.push_back((string)(labelarray->At(i)->GetName())); + TObjArray *IOVarray = runlist.Tokenize(","); + vector IOVlist; + for(int i=0; i < IOVarray->GetEntries(); i++)IOVlist.push_back(stoi(IOVarray->At(i)->GetName())); + vector pixelupdateruns; + TObjArray *PIXarray = pixelupdatelist.Tokenize(","); + for(int i=0; i < PIXarray->GetEntries(); i++)pixelupdateruns.push_back(stoi(PIXarray->At(i)->GetName())); + vector geometries; + vector colours; + TObjArray *geometrieandcolourspairs = geometrieandcolours.Tokenize(","); + for (int i=0; i < geometrieandcolourspairs->GetEntries(); i++) { + TObjArray *geomandcolourvec = TString(geometrieandcolourspairs->At(i)->GetName()).Tokenize(":"); + geometries.push_back(geomandcolourvec->At(0)->GetName()); + colours.push_back((Color_t)(atoi(geomandcolourvec->At(1)->GetName()))); + } + DMRtrends(IOVlist,labels,Year,pathtoDMRs.Data(),geometries,colours,outputdirectory.Data(),showpixelupdate, pixelupdateruns,showlumi,FORCE); + + + return 0; +} diff --git a/Alignment/OfflineValidation/bin/README.md b/Alignment/OfflineValidation/bin/README.md new file mode 100644 index 0000000000000..b98748aec4287 --- /dev/null +++ b/Alignment/OfflineValidation/bin/README.md @@ -0,0 +1,31 @@ +# DMRtrends +Tool for retrieving and plotting the trend of the distribution of medians of residuals (DMRs) along a period of data taking. + +Instructions for running the macros: + +The macro can be executed in two ways: + +1) From command line: "DMRtrends IOVlist labels Year pathtoDMRs geometriesandcolourspairs outputdirectory pixelupdatelist showpixelupdate showlumi FORCE" +2) By editing the parameters directly in the main() function in DMRtrends.cc and executing the macro without arguments + +List of arguments: +-IOVlist: string containing the list of IOVs separated by a "," +-labels: string containing labels that must be part of the input files +-Year: string containing the year of the studied runs (needed to retrieve the lumi-per-run file) +-pathtoDMRs: string containing the path to the directory where the DMRs are stored +-geometrieandcolours: string containing the list of geometries and colors in the following way name1:color1,name2:color2 etc. +-outputdirectory: string containing the output directory for the plots +-pixelupdatelist: string containing the list of pixelupdates separated by a "," +-showpixelupdate: boolean, if set to true will allow to plot vertical lines in the canvas corresponding to the pixel updates +-showlumi: boolean, if set to false the trends will be presented in function of the run (IOV) number, if set to true the integrated luminosity is used on the x axis +-FORCE: boolean, if set to true the plots will be made regardless of possible errors. + +In both cases the macro needs to be compiled with "scram b", a BuildFile is already provided for that. + + +Please note: +- If some DMRs haven't been computed correctly the macro will stop. The FORCE boolean has to be set to true to run regardless of these errors. In this case the trends will appear with "holes", as some points are not plotted. Warnings and errors are still present in the output. +- If the showlumi boolean is set to true the macro will try to retrieve the lumi-per-run/IOV txt files provided in the ../interface directory. The file names are currently hardcoded, and defined in the lumifileperyear() function. +- The Year string is currently only used to identify the correct lumi-per-run/IOV files to read, later it will be also used to select the High Level Structures and the number of layers/disks per structure + +For questions regarding the tool please contact: andrea.cardini@desy.de \ No newline at end of file diff --git a/Alignment/OfflineValidation/data/lumiperIOV2017.txt b/Alignment/OfflineValidation/data/lumiperIOV2017.txt new file mode 100644 index 0000000000000..b6ec50083b483 --- /dev/null +++ b/Alignment/OfflineValidation/data/lumiperIOV2017.txt @@ -0,0 +1,59 @@ +290543 184.007 +296702 241.267 +296966 1585.38 +297224 38.13 +297281 690.37 +297429 203.13 +297467 129.04 +297484 433.39 +297494 40.38 +297503 272.57 +297557 297.47 +297599 396.18 +297620 202.27 +297660 169.21 +297670 203.37 +297678 154.99 +298996 107.46 +299062 209.18 +299096 171.14 +299184 239.02 +299327 54.26 +299368 327.69 +299381 90.48 +299443 139.09 +299480 370.17 +299592 236.84 +299594 320.68 +299649 93.77 +300087 541 +300155 591.88 +300233 147.93 +300237 303.24 +300280 358.25 +300364 60.72 +300389 63.98 +300399 287.65 +300459 423.12 +300497 71.3 +300515 435.9 +300538 100.3 +300551 294.7 +300574 527.6 +300636 275.5 +300673 248.9 +300780 300.4 +300806 203.5 +300812 159.9 +301046 1255.8 +301417 2574.7 +302131 3102.8 +302573 648 +302635 540.2 +303825 1575.4 +303998 2348.9 +304170 2085.6 +304505 2043.7 +304672 1495.5 +305040 1018.6 +305081 13615.3 diff --git a/Alignment/OfflineValidation/data/lumiperIOV2018.txt b/Alignment/OfflineValidation/data/lumiperIOV2018.txt new file mode 100644 index 0000000000000..f99c08619d485 --- /dev/null +++ b/Alignment/OfflineValidation/data/lumiperIOV2018.txt @@ -0,0 +1,67 @@ +315257 1099.03 +315488 232.75 +315489 106.54 +315506 523.34 +315640 469.61 +315689 330.13 +315690 432.04 +315713 1005.67 +315790 167.86 +315800 647.98 +315973 294.59 +316058 296.36 +316060 201.25 +316082 864.39 +316187 898.48 +316200 181.48 +316216 256.84 +316218 285.47 +316239 527.9 +316271 29.29 +316361 81.81 +316363 7.18 +316378 192.84 +316456 519.75 +316470 179.66 +316505 389.06 +316559 0 +316569 741.8 +316665 1198.1 +316758 2280.6 +317080 473.3 +317182 391.7 +317212 585.4 +317295 662.5 +317339 203.4 +317382 952.6 +317438 787.7 +317527 2027.2 +317661 862.5 +318228 0 +318712 457.1 +319337 1004.3 +319460 5770.7 +320377 0 +320569 96.8 +320688 151.3 +320712 486 +320809 104.8 +320821 201.3 +320823 234.1 +320838 271.7 +320853 291.3 +320856 271.3 +320917 479.9 +320933 251.1 +320936 90.5 +320980 110.6 +321004 306.6 +321009 115.2 +321051 451.8 +321067 379.3 +321119 744.3 +321149 457.3 +321164 800 +321219 185.1 +321221 293.8 +321282 367.0 diff --git a/Alignment/OfflineValidation/data/lumiperrun2017.txt b/Alignment/OfflineValidation/data/lumiperrun2017.txt new file mode 100644 index 0000000000000..18d536a105712 --- /dev/null +++ b/Alignment/OfflineValidation/data/lumiperrun2017.txt @@ -0,0 +1,963 @@ +290543 0 +294927 0.008 +294928 0.012 +294929 0.01 +294931 0.011 +294932 0.01 +294933 0.01 +294934 0.009 +294935 0.011 +294936 0.01 +294937 0.009 +294939 0.008 +294940 0.008 +294947 0.008 +294949 0.006 +294950 0.004 +294951 0.004 +294952 0.004 +294953 0.004 +294954 0.004 +294955 0.004 +294956 0.004 +294957 0.003 +294960 0.003 +294986 0.008 +294987 0.006 +294988 0.004 +294990 0.009 +294992 0 +294993 0.007 +294995 0.007 +294997 0.007 +294999 0.006 +295001 0.009 +295122 0.019 +295123 0.017 +295124 0.016 +295125 0.017 +295126 0.015 +295127 0.017 +295128 0.212 +295129 0.004 +295130 0.01 +295131 0.143 +295132 0.003 +295133 0.008 +295134 0.004 +295135 0.028 +295192 0.006 +295193 0.002 +295194 0.018 +295197 0.015 +295198 0.001 +295199 0.009 +295200 0.016 +295201 0.014 +295202 0.013 +295203 0.015 +295204 0.019 +295208 0 +295209 0.157 +295210 0.063 +295315 0.133 +295318 0.208 +295319 0.003 +295320 0 +295321 0 +295322 0.037 +295323 0.082 +295324 0.11 +295325 0.041 +295326 0.032 +295327 0.043 +295328 0.167 +295329 0.023 +295330 0.18 +295331 0.045 +295332 0.131 +295334 0.068 +295335 0.05 +295336 0.004 +295337 0.019 +295339 0.116 +295340 0.619 +295341 0.062 +295342 0.055 +295343 0.039 +295344 0.056 +295345 0.051 +295346 0.016 +295347 0.066 +295348 0.087 +295349 0.005 +295371 0.105 +295376 0.906 +295377 0.091 +295378 0.092 +295379 0.087 +295380 0.093 +295381 1.261 +295390 1.363 +295391 0.676 +295392 0.119 +295393 0.178 +295394 0 +295395 0.773 +295436 1.29 +295437 0.542 +295438 0.519 +295439 0.474 +295440 0.497 +295441 0.001 +295442 0 +295443 0.001 +295444 0.336 +295445 0.64 +295446 0.545 +295447 0.49 +295448 0.47 +295449 0.462 +295450 0.464 +295451 0.159 +295452 0.057 +295453 0.494 +295454 0.484 +295455 0.456 +295456 0.456 +295457 0.448 +295458 0.49 +295459 0.475 +295460 0.316 +295463 25.302 +295600 0.822 +295602 0.411 +295603 2.223 +295604 0.129 +295605 7.942 +295606 2.416 +295607 0.226 +295608 1.897 +295610 1.36 +295613 7.338 +295628 0.787 +295632 0.421 +295634 0.093 +295635 0.098 +295636 0.143 +295637 0.159 +295638 0.321 +295639 0.344 +295640 0.338 +295641 0.336 +295642 0.338 +295644 0.511 +295645 0.328 +295646 0.363 +295647 0.302 +295648 0.309 +295649 0.326 +295650 0.328 +295651 0.105 +295652 0.068 +295655 8.232 +295953 4.216 +295969 0.032 +295976 0.006 +295977 0.318 +296070 1.214 +296071 0.005 +296073 0.029 +296074 0.759 +296076 0.651 +296077 0.723 +296078 0.64 +296079 0.716 +296081 0.537 +296082 0.083 +296083 0.698 +296084 0.683 +296085 0.645 +296086 0.026 +296087 0.598 +296088 0.668 +296089 0.654 +296090 0.477 +296091 0.746 +296092 0.735 +296093 0.64 +296094 0.011 +296095 0.695 +296096 0.643 +296097 0.611 +296098 0.683 +296099 0.538 +296100 0.58 +296101 0.586 +296102 0.028 +296103 0.683 +296104 0.816 +296107 0.54 +296108 0.578 +296109 0.578 +296110 0.556 +296111 0.574 +296112 0.556 +296113 0.567 +296114 1.134 +296115 0.885 +296116 5.767 +296168 1.274 +296172 1.862 +296173 43.167 +296174 1.84 +296641 0.001 +296642 0.018 +296643 0.008 +296644 0.007 +296646 0.008 +296647 0.007 +296663 2.061 +296664 1.863 +296665 1.375 +296666 1.004 +296668 0.939 +296669 1.117 +296671 0 +296674 1.37 +296675 0.955 +296676 1.351 +296677 2.217 +296678 1.12 +296679 0.958 +296680 1.115 +296702 12.152 +296786 77.551 +296787 7.424 +296788 4.713 +296789 1.232 +296790 1.077 +296791 0.307 +296795 1.491 +296796 5.846 +296797 1.279 +296799 0.252 +296800 1.126 +296801 0.438 +296802 1.22 +296866 3.785 +296867 15.121 +296868 1.844 +296869 1.622 +296870 1.61 +296871 1.633 +296872 1.496 +296873 1.487 +296874 1.556 +296875 1.343 +296876 1.484 +296877 1.513 +296878 1.373 +296879 1.584 +296880 4.109 +296881 0.791 +296887 46.81 +296888 20.177 +296895 0.588 +296897 5.519 +296898 2.985 +296899 1.319 +296900 2.672 +296901 1.454 +296902 1.284 +296966 18.559 +296967 3.178 +296968 2.053 +296969 9.912 +296970 23.046 +296971 2.584 +296972 20.646 +296976 18.109 +296977 51.17 +296978 13.078 +296979 1.074 +296980 12.322 +297003 9.149 +297004 2.559 +297006 2.156 +297007 2.153 +297009 1.874 +297010 2.301 +297011 2.155 +297012 2.143 +297015 2.174 +297016 2.101 +297017 1.943 +297018 2.209 +297019 2.314 +297047 4.239 +297048 2.194 +297049 2.231 +297050 103.287 +297056 28.463 +297057 116.596 +297099 7.258 +297100 71.52 +297101 162.004 +297113 50.809 +297114 32.427 +297168 3.591 +297169 2.064 +297170 1.279 +297171 14.297 +297175 15.606 +297176 42.254 +297177 30.027 +297178 200.45 +297179 9.737 +297180 13.682 +297181 6.618 +297211 11.007 +297215 12.017 +297218 3.629 +297219 427.13 +297224 13.007 +297225 2.256 +297227 22.868 +297281 12.215 +297282 4.326 +297283 4.184 +297284 4.292 +297285 3.937 +297286 5.335 +297287 4.005 +297288 3.869 +297289 3.82 +297290 3.722 +297291 4.224 +297292 171.087 +297293 27.926 +297296 85.852 +297308 9.603 +297359 40.936 +297411 202.088 +297424 31.217 +297425 41.21 +297426 26.522 +297429 17.174 +297430 45.888 +297431 39.065 +297432 25.555 +297433 29.723 +297434 28.822 +297435 16.903 +297467 32.177 +297468 22.624 +297469 18.964 +297474 6.301 +297483 48.97 +297484 57.036 +297485 98.144 +297486 123.975 +297487 97.387 +297488 56.849 +297494 5.615 +297495 4.939 +297496 6.84 +297497 4.57 +297498 4.538 +297499 4.547 +297501 4.728 +297502 4.607 +297503 186.983 +297504 10.96 +297505 74.619 +297557 109.55 +297558 67.211 +297562 72.541 +297563 46.549 +297598 1.622 +297599 106.449 +297603 98.936 +297604 82.157 +297605 71.813 +297606 36.83 +297620 82.18 +297656 115.925 +297657 0.868 +297658 0.018 +297659 3.272 +297660 51.159 +297661 21.801 +297662 3.508 +297663 3.634 +297664 7.139 +297665 58.59 +297666 23.377 +297670 8.107 +297671 12.316 +297672 4.484 +297673 4.249 +297674 52.881 +297675 121.338 +297678 0.044 +297722 92.869 +297723 62.076 +298653 0.001 +298678 0.004 +298996 23.753 +298997 5.425 +298998 0.218 +299000 8.544 +299042 2.419 +299061 67.1 +299062 60.61 +299064 16.685 +299065 60.938 +299067 70.948 +299096 25.083 +299149 111.906 +299178 16.895 +299180 17.228 +299183 0.021 +299184 126.94 +299185 24.172 +299316 11.508 +299317 8.984 +299318 11.713 +299324 4.686 +299325 45.922 +299326 5.095 +299327 15.596 +299329 38.663 +299368 33.96 +299369 80.807 +299370 156.517 +299380 56.408 +299381 12.426 +299394 6.195 +299395 40.232 +299396 17.804 +299420 13.825 +299443 36.517 +299450 13.221 +299477 12.124 +299478 46.532 +299479 30.7 +299480 169.715 +299481 200.45 +299592 27.149 +299593 209.696 +299594 62.037 +299595 25.696 +299597 87.687 +299614 61.366 +299616 75.109 +299617 8.778 +299649 91.96 +299996 0.054 +300018 0.018 +300027 0.007 +300043 0.021 +300079 1.713 +300087 13.598 +300088 0.377 +300105 1.265 +300106 20.138 +300107 14.149 +300117 7.067 +300122 302.734 +300123 103.368 +300124 78.307 +300155 288.121 +300156 12.014 +300157 172.245 +300226 119.494 +300233 32.557 +300234 14.933 +300235 50.549 +300236 49.894 +300237 166.194 +300238 56.428 +300239 31.735 +300240 48.886 +300280 158.246 +300281 1.608 +300282 43.362 +300283 5.862 +300284 149.167 +300364 4.47 +300365 3.645 +300366 2.976 +300367 3.103 +300368 3.066 +300369 3.316 +300370 3.263 +300371 3.042 +300372 2.041 +300373 3.194 +300374 3.211 +300375 25.391 +300389 32.939 +300390 3.493 +300391 3.342 +300392 3.448 +300393 3.507 +300394 3.365 +300395 3.412 +300396 3.324 +300397 3.527 +300398 3.624 +300399 4.285 +300400 162.809 +300401 120.559 +300459 83.07 +300461 23.965 +300462 23.548 +300463 30.979 +300464 59.54 +300466 121.62 +300467 80.407 +300497 41.242 +300498 0.018 +300499 0.003 +300500 0.007 +300514 30.005 +300515 263.831 +300516 19.408 +300517 152.714 +300538 10.382 +300539 60.775 +300545 25.888 +300548 3.259 +300551 23.509 +300552 13.394 +300558 118.955 +300560 138.758 +300574 24.28 +300575 12.365 +300576 274.098 +300631 47.336 +300632 4.123 +300633 122.455 +300635 42.953 +300636 275.562 +300673 8.29 +300674 7.954 +300675 2.935 +300676 7.686 +300742 89.558 +300777 132.465 +300780 80.813 +300785 219.585 +300806 55.423 +300811 148.055 +300812 15.036 +300816 36.65 +300817 108.228 +301046 4.405 +301086 19.941 +301141 1.287 +301142 97.836 +301161 99.822 +301165 15.833 +301179 2.375 +301180 15.075 +301183 46.445 +301281 19.248 +301283 122.07 +301298 158.456 +301323 168.528 +301330 66.196 +301359 58.718 +301383 0.47 +301384 95.893 +301391 35.555 +301392 111.762 +301393 2.806 +301394 0.016 +301395 0.023 +301396 3.781 +301397 95.503 +301398 0.565 +301399 13.135 +301417 70.44 +301447 81.522 +301448 48.686 +301449 49.891 +301450 20.446 +301461 99.769 +301472 140.531 +301473 0.006 +301474 0.026 +301475 1.568 +301476 108.771 +301480 18.359 +301519 34.172 +301524 42.824 +301525 8.266 +301528 2.16 +301529 6.66 +301530 14.509 +301531 48.917 +301532 63.676 +301567 64.474 +301627 133.518 +301664 71.724 +301665 72.371 +301694 18.602 +301912 45.227 +301913 6.036 +301914 36.061 +301941 75.901 +301959 279.448 +301960 15.326 +301969 6.769 +301970 23.879 +301984 56.817 +301985 60.906 +301986 55.046 +301987 124.204 +301997 66.23 +301998 221.828 +302019 9.734 +302026 5.245 +302027 0 +302029 15.525 +302030 0 +302031 130.848 +302033 5.23 +302034 0.489 +302036 4.152 +302037 0.908 +302038 0.581 +302040 21.172 +302041 7.814 +302042 55.478 +302043 22.045 +302131 117.987 +302159 16.589 +302163 148.603 +302165 6.928 +302166 2.037 +302225 117.852 +302228 39.543 +302229 68.349 +302239 0.003 +302240 140.805 +302262 77.401 +302263 167.241 +302277 55.33 +302279 5.955 +302280 13.077 +302322 99.769 +302328 97.878 +302337 21.149 +302342 9.609 +302343 15.644 +302344 70.461 +302349 0.005 +302350 17.992 +302388 131.17 +302392 77.275 +302393 160.822 +302448 315.761 +302472 158.522 +302473 61.522 +302474 44.088 +302475 0.101 +302476 34.178 +302479 70.763 +302484 38.163 +302485 176.631 +302486 0.006 +302487 0.008 +302488 0.408 +302489 0.043 +302490 0.004 +302491 0.005 +302492 8.517 +302493 0.144 +302494 87.877 +302509 13.949 +302513 12.88 +302522 0.997 +302523 10.987 +302525 147.326 +302526 89.629 +302548 16.283 +302550 0.797 +302551 0.115 +302553 37.757 +302554 0.093 +302555 2.071 +302563 0.652 +302564 0.005 +302565 0.153 +302566 14.045 +302567 7.455 +302569 0.042 +302570 8.084 +302571 7.438 +302572 55.837 +302573 196.123 +302596 179.171 +302597 148.879 +302634 123.737 +302635 193.516 +302646 0.214 +302651 30.713 +302654 65.319 +302660 0.434 +302661 9.746 +302663 137.094 +303790 0 +303818 0.034 +303819 0.88 +303824 102.249 +303825 24.108 +303832 334.821 +303838 402.09 +303885 415.988 +303948 386.02 +303989 12.366 +303998 76.523 +303999 179.14 +304000 11.033 +304062 386.349 +304119 21.934 +304120 72.611 +304125 342.197 +304144 540.104 +304158 377.191 +304169 341.853 +304170 77.44 +304196 4.138 +304197 2.284 +304198 5.563 +304199 0.618 +304200 88.753 +304204 154.25 +304209 123.533 +304291 3.489 +304292 359.515 +304333 370.332 +304354 68.97 +304366 424.19 +304446 19.422 +304447 371.877 +304448 1.229 +304449 0.265 +304451 7.492 +304452 2.272 +304505 8.024 +304506 119.703 +304507 50.757 +304508 250.911 +304562 223.99 +304616 257.048 +304625 136.778 +304626 2.606 +304654 174.361 +304655 232.686 +304661 55.642 +304662 43.532 +304663 177.925 +304671 309.677 +304672 13.451 +304737 24.6 +304738 410.97 +304739 1.872 +304740 40.992 +304776 9.743 +304777 158.495 +304778 269.721 +304797 565.699 +304911 0 +305040 32.259 +305043 17.652 +305044 99.781 +305045 203.411 +305046 112.571 +305059 158.567 +305062 1.305 +305063 9.589 +305064 383.454 +305081 315.699 +305112 401.878 +305113 12.603 +305114 87.379 +305178 17.131 +305179 3.958 +305180 0.588 +305181 0.582 +305182 1.007 +305183 77.312 +305184 0.102 +305185 0.359 +305186 122.53 +305188 200.223 +305202 208.533 +305204 256.702 +305207 318.551 +305208 83.641 +305234 13.245 +305236 6.486 +305237 338.407 +305247 122.804 +305248 258.32 +305249 9.47 +305250 2.438 +305252 96.572 +305282 46.289 +305310 129.589 +305311 47.358 +305312 68.317 +305313 170.874 +305314 76.471 +305336 66.635 +305338 33.083 +305341 151.794 +305349 3.899 +305350 3.916 +305351 181.03 +305358 50.26 +305364 30.795 +305365 250.672 +305366 236.849 +305376 33.626 +305377 400.511 +305405 160.26 +305406 321.667 +305440 83.376 +305441 36.888 +305516 180.437 +305517 33.976 +305518 235.522 +305586 186.703 +305588 33.842 +305589 163.428 +305590 156.352 +305636 529.294 +305766 266.181 +305809 46.645 +305814 449.3 +305821 240.696 +305832 58.679 +305840 252.297 +305841 0.02 +305842 116.491 +305862 202.42 +305898 230.591 +305902 154.848 +305967 10.514 +306029 9.661 +306030 34.817 +306036 0.372 +306037 12.217 +306038 43.987 +306041 99.914 +306042 100.158 +306048 32.17 +306049 75.553 +306051 73.142 +306091 205.228 +306092 221.438 +306093 0.029 +306095 76.325 +306121 28.879 +306122 40.472 +306125 567.75 +306126 31.65 +306134 7.31 +306135 345.123 +306137 1.093 +306138 212.679 +306139 102.931 +306153 26.753 +306154 339.244 +306155 221.028 +306169 67.046 +306170 1.149 +306171 36.212 +306416 0.018 +306417 26.004 +306418 21.266 +306419 18.366 +306420 34.099 +306422 36.771 +306423 85.789 +306425 43.121 +306432 33.79 +306454 27.08 +306455 1.63 +306456 236.925 +306457 6.713 +306458 61.464 +306459 310.102 +306460 4.048 +306461 0.514 +306462 0.893 +306546 0.006 +306548 0.001 +306549 0.004 +306550 0.075 +306553 4.007 +306563 2.497 +306572 22.086 +306580 28.881 +306584 1.696 +306595 1.501 +306598 6.231 +306604 16.97 +306629 15.531 +306630 2.139 +306631 17.432 +306636 0.099 +306645 0.251 +306646 0.176 +306647 0.04 +306651 0.292 +306652 0.142 +306653 1.808 +306654 2.199 +306656 2.557 +306657 13.422 +306705 25.841 +306709 28.12 +306772 20.615 +306773 10.523 +306776 0.161 +306777 8.137 +306793 38.425 +306794 7.24 +306801 24.496 +306826 7.987 +306896 0.018 +306897 0.003 +306926 1.905 +306929 4.56 +306936 43.566 +307014 24.117 +307015 7.054 +307016 5.631 +307017 13.81 +307042 10.995 +307044 1.417 +307045 0.823 +307046 1.38 +307047 9.371 +307048 3.394 +307049 0.443 +307050 5.616 +307051 9.127 +307052 0.365 +307053 0.88 +307054 1.023 +307055 15.762 +307062 14.355 +307063 4.125 +307073 16.141 +307075 2.009 +307076 30.169 +307082 23.845 diff --git a/Alignment/OfflineValidation/data/lumiperrun2018.txt b/Alignment/OfflineValidation/data/lumiperrun2018.txt new file mode 100644 index 0000000000000..6ad5cbb91d1e6 --- /dev/null +++ b/Alignment/OfflineValidation/data/lumiperrun2018.txt @@ -0,0 +1,551 @@ +314881 0 +315257 7.979 +315258 0.017 +315259 14.366 +315264 39.224 +315265 6.684 +315267 36.402 +315270 78.249 +315322 177.319 +315339 92.546 +315357 151.55 +315361 116.836 +315363 18.48 +315365 4.018 +315366 100.834 +315420 254.524 +315488 232.752 +315489 102.182 +315490 4.357 +315506 27.973 +315509 16.619 +315510 100.746 +315512 228.931 +315543 36.618 +315555 21.9 +315556 8.215 +315557 82.335 +315640 10.443 +315641 1.206 +315642 30.611 +315644 61.476 +315645 158.932 +315646 183.546 +315647 7.609 +315648 15.787 +315689 330.131 +315690 115.631 +315702 22.597 +315703 152.389 +315704 14.132 +315705 127.295 +315713 352.095 +315721 207.02 +315741 24.216 +315764 111.716 +315770 119.13 +315784 67.446 +315785 102.831 +315786 21.21 +315790 167.864 +315800 208.649 +315801 95.328 +315840 343.999 +315973 275.276 +315974 19.316 +316058 133.08 +316059 163.282 +316060 187.857 +316061 9.953 +316062 3.441 +316082 137.53 +316109 0.552 +316110 79.017 +316111 14.573 +316112 0 +316113 19.663 +316114 351.729 +316151 0.75 +316153 245.686 +316186 14.893 +316187 509.898 +316199 388.575 +316200 2.148 +316201 106.02 +316202 73.318 +316216 171.744 +316217 85.089 +316218 236.9 +316219 48.576 +316239 202.781 +316240 273.3 +316241 51.816 +316271 29.294 +316361 26.87 +316362 54.941 +316363 5.064 +316377 2.112 +316378 3.271 +316379 8.038 +316380 171.911 +316455 9.616 +316456 0.555 +316457 316.79 +316469 202.407 +316470 112.705 +316472 66.96 +316505 389.045 +316559 0 +316569 478.488 +316590 183.429 +316613 31.188 +316615 48.728 +316664 0.005 +316665 94.986 +316666 269.016 +316667 40.735 +316700 124.498 +316701 138.597 +316702 92.044 +316715 5.681 +316716 59.58 +316717 61.15 +316718 95.539 +316719 31.79 +316720 40.114 +316721 3.777 +316722 129.484 +316723 11.09 +316758 440.119 +316766 540.971 +316876 209.502 +316877 108.483 +316879 37.391 +316928 43.315 +316944 477.148 +316985 167.286 +316993 72.331 +316994 4.587 +316995 179.421 +317080 8.123 +317087 259.554 +317088 0.008 +317089 205.613 +317182 391.718 +317212 49.769 +317213 120.98 +317279 64.932 +317291 267.785 +317292 81.932 +317295 4.155 +317296 21.482 +317297 125.799 +317319 52.026 +317320 445.563 +317338 13.521 +317339 67.871 +317340 135.492 +317382 23.644 +317383 22.036 +317391 3.201 +317392 480.456 +317434 76.125 +317435 347.199 +317438 52.744 +317475 30.501 +317478 7.632 +317479 3.955 +317480 4.569 +317481 6.947 +317482 6.049 +317484 159.279 +317488 174.899 +317509 116.085 +317510 3.638 +317511 117 +317512 104.356 +317527 434.963 +317591 107.981 +317626 509.817 +317640 251.58 +317641 257.744 +317648 33.224 +317649 185.578 +317650 246.268 +317661 377.607 +317663 147.601 +317664 0 +317683 114.086 +317696 223.282 +318227 0 +318228 0 +318712 0 +318733 2.69 +318816 28.774 +318819 4.894 +318820 10.196 +318828 13.317 +318872 88.558 +318874 94.917 +318876 44.263 +318877 153.063 +318944 0.001 +319077 16.405 +319310 0.004 +319337 224.593 +319347 205.418 +319348 4.855 +319349 39.728 +319449 243.493 +319450 201.193 +319456 85.04 +319459 16.604 +319460 0 +319486 19.919 +319503 88.691 +319524 444.821 +319526 67.425 +319528 57.858 +319579 771.257 +319625 68.219 +319639 392.208 +319656 85.233 +319657 49.621 +319658 59.878 +319659 20.962 +319678 92.073 +319687 16.414 +319697 60.05 +319698 35.741 +319756 470.238 +319840 48.945 +319841 20.616 +319847 1.494 +319848 18.293 +319849 166.303 +319851 1.079 +319852 0.06 +319853 69.835 +319854 52.974 +319908 18.294 +319909 1.088 +319910 291.925 +319912 12.855 +319913 11.999 +319914 6.576 +319915 83.175 +319941 91.184 +319942 17.034 +319950 64.012 +319991 270.744 +319992 62.668 +319993 175.454 +320002 48.851 +320006 109.549 +320007 43.194 +320008 21.598 +320009 29.401 +320010 71.342 +320011 58.384 +320012 17.441 +320023 95.188 +320024 120.883 +320025 28.769 +320026 48.008 +320038 210.015 +320039 7.856 +320040 169.72 +320058 6.772 +320059 39.241 +320060 15.071 +320061 17.52 +320062 6.672 +320063 21.2 +320064 62.044 +320065 218.132 +320377 0 +320500 0.033 +320569 0.059 +320570 0.084 +320571 0.013 +320673 62.703 +320674 33.949 +320688 151.226 +320712 67.332 +320757 112.969 +320804 305.407 +320807 0.322 +320809 104.81 +320821 58.352 +320822 142.985 +320823 76.341 +320824 157.749 +320838 88.699 +320840 134.611 +320841 48.355 +320853 113.509 +320854 37.854 +320855 139.939 +320856 31.978 +320857 50.441 +320858 35.817 +320859 4.998 +320887 100.694 +320888 40.999 +320916 6.408 +320917 456.336 +320920 23.568 +320933 50.139 +320934 200.871 +320936 74.726 +320941 15.816 +320980 37.865 +320995 25.382 +320996 47.345 +321004 45.439 +321005 18.327 +321006 49.413 +321007 193.462 +321009 14.042 +321010 54.622 +321011 27.616 +321012 18.893 +321051 317.887 +321055 133.874 +321067 178.353 +321068 150.153 +321069 50.809 +321119 60.087 +321121 16.138 +321122 122.55 +321123 0.008 +321124 189.134 +321126 81.369 +321134 8.787 +321138 145.742 +321140 120.524 +321149 445.236 +321162 12.012 +321164 26.711 +321165 0.384 +321166 3.431 +321167 280.825 +321177 175.656 +321178 24.857 +321218 288.169 +321219 185.067 +321221 6.144 +321230 23.581 +321231 14.749 +321232 6.223 +321233 236.103 +321261 4.929 +321262 2.101 +321282 0 +321283 122.297 +321294 20.945 +321295 209.065 +321296 14.737 +321305 614.146 +321310 16.883 +321311 0.493 +321312 61.743 +321313 27.805 +321393 52.713 +321396 371.482 +321397 54.046 +321414 387.821 +321415 162.276 +321431 57.803 +321432 17.025 +321433 43.422 +321434 183.96 +321436 141.274 +321457 491.855 +321461 22.062 +321475 483.601 +321709 0.027 +321710 17.456 +321712 91.687 +321730 104.71 +321732 360.769 +321735 24.291 +321755 218.614 +321758 45.974 +321759 2.138 +321760 157.24 +321773 28.281 +321774 49.459 +321775 17.223 +321776 14.747 +321777 87.765 +321778 38.719 +321780 128.051 +321781 115.23 +321794 66.906 +321796 0.529 +321813 145.648 +321815 5.198 +321817 150.842 +321818 140.525 +321820 33.35 +321831 252.008 +321832 118.434 +321833 75.564 +321834 51.549 +321879 108.133 +321880 42.605 +321887 281.571 +321908 147.707 +321909 346.853 +321917 268.144 +321919 1.778 +321933 103.457 +321960 7.932 +321961 134.145 +321973 364.865 +321975 149.073 +321988 416.575 +321990 83.153 +322013 1.995 +322014 7.142 +322022 466.979 +322040 14.843 +322057 9.474 +322068 236.965 +322079 154.185 +322088 176.924 +322106 286.044 +322113 41.67 +322118 275.685 +322179 477.364 +322201 86.1 +322204 317.516 +322222 94.911 +322252 426.757 +322317 20.18 +322319 56.178 +322322 328.109 +322324 71.449 +322332 318.745 +322348 419.67 +322355 34.663 +322356 237.438 +322381 181.585 +322407 174.54 +322430 238.417 +322431 234.431 +322480 110.92 +322483 0 +322487 0 +322492 294.315 +322510 3.162 +322599 95.947 +322602 24.342 +322603 2.761 +322605 90.614 +322616 18.079 +322617 138.687 +322625 341.969 +322633 52.231 +323413 0 +323414 6.606 +323416 14.198 +323417 5.998 +323418 9.058 +323419 10.317 +323420 2.828 +323421 2.754 +323422 0.074 +323423 22.385 +323470 83.847 +323471 76.015 +323472 19.45 +323473 55.094 +323474 78.721 +323475 15.38 +323487 157.905 +323488 197.78 +323492 5.95 +323493 27.663 +323495 34.141 +323524 182.26 +323525 246.388 +323526 67.832 +323693 41.09 +323696 89.73 +323702 148.513 +323725 119.823 +323726 14.728 +323727 253.007 +323755 302.018 +323775 48.452 +323778 273.365 +323790 279.544 +323794 16.429 +323841 156.807 +323857 97.588 +323940 433.407 +323954 15.48 +323976 15.171 +323978 22.087 +323980 68.171 +323983 57.194 +323997 130.011 +324021 254.578 +324022 132.29 +324077 244.9 +324201 366.809 +324202 39.72 +324205 23.278 +324206 17.783 +324207 4.108 +324209 17.711 +324237 76.231 +324245 421.399 +324293 518.939 +324315 70.782 +324318 101.426 +324420 202.661 +324564 0.016 +324570 0 +324571 0.013 +324729 15.935 +324747 310.581 +324764 30.333 +324765 88.664 +324769 47.322 +324772 19.602 +324785 187.095 +324791 247.724 +324835 111.572 +324840 27.864 +324841 303.483 +324846 70.251 +324878 409.002 +324897 51.027 +324970 486.994 +324980 527.983 +324997 42.308 +324998 114.778 +324999 3.91 +325000 95.258 +325001 121.488 +325022 436.917 +325057 121.483 +325097 18.725 +325098 2.005 +325099 139.74 +325100 74.857 +325101 119.275 +325110 3.279 +325111 3.834 +325113 21.895 +325114 1.396 +325117 87.506 +325159 62.202 +325168 4.341 +325169 5.634 +325170 265.367 +325172 69.03 +325175 1.504 diff --git a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C index 5e5b7987c0bba..210fcbea574f5 100644 --- a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C +++ b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C @@ -42,7 +42,19 @@ #include #include + +/*! \class PlotAlignmentValidation + * \brief Class PlotAlignmentValidation + * Class used as the last step for Offline Track Validation tool. + * The main goal of this class is creating the plots regarding DMRs and Surface Deformations for modules and substructures. + */ + + //------------------------------------------------------------------------------ +/*! \fn PlotAlignmentValidation + * \brief Constructor for the class + */ + PlotAlignmentValidation::PlotAlignmentValidation(bool bigtext) : bigtext_(bigtext) { setOutputDir("."); @@ -66,12 +78,18 @@ PlotAlignmentValidation::PlotAlignmentValidation(bool bigtext) : bigtext_(bigtex } //------------------------------------------------------------------------------ +/*! \fn PlotAlignmentValidation + * \brief Constructor for the class. This function also retrieves the list of root files used to produce DMRs and Surface Deformations + */ PlotAlignmentValidation::PlotAlignmentValidation(const char *inputFile,std::string legendName, int lineColor, int lineStyle, bool bigtext) : PlotAlignmentValidation(bigtext) { loadFileList(inputFile, legendName, lineColor, lineStyle); } //------------------------------------------------------------------------------ +/*! \fn ~PlotAlignmentValidation + * \brief Default destructor + */ PlotAlignmentValidation::~PlotAlignmentValidation() { @@ -85,19 +103,35 @@ PlotAlignmentValidation::~PlotAlignmentValidation() } //------------------------------------------------------------------------------ +/*! + * \fn openSummaryFile + * \brief Create/open the root and txt summary files, where the DMR histograms and the associtated mean/sigma are stored respectively + */ + + void PlotAlignmentValidation::openSummaryFile() { if (!openedsummaryfile) { openedsummaryfile = true; - summaryfile.open(outputDir+"/"+summaryfilename); + summaryfile.open(outputDir+"/"+summaryfilename+".txt"); + //Rootfile introduced to store the DMR histograms + rootsummaryfile= new TFile(outputDir+"/"+summaryfilename+".root","RECREATE"); + for (auto vars : sourceList) { summaryfile << "\t" << vars->getName(); } summaryfile << "\tformat={}\n"; + }else{ + //Check for the rootfile to be open, and open it in case it is not already. + if (!rootsummaryfile->IsOpen()) rootsummaryfile->Open(outputDir+"/"+summaryfilename+".root","UPDATE"); + } } //------------------------------------------------------------------------------ +/*! \fn loadFileList + * \brief Add to the list of sources the rootfile associated to a particular geometry + */ void PlotAlignmentValidation::loadFileList(const char *inputFile, std::string legendName, int lineColor, int lineStyle) { @@ -110,6 +144,9 @@ void PlotAlignmentValidation::loadFileList(const char *inputFile, std::string le } //------------------------------------------------------------------------------ +/*! \fn useFitForDMRplots + * \brief Store the selected boolean in one of the private members of the class + */ void PlotAlignmentValidation::useFitForDMRplots(bool usefit) { @@ -118,6 +155,10 @@ void PlotAlignmentValidation::useFitForDMRplots(bool usefit) } //------------------------------------------------------------------------------ +/*! \fn numberOfLayers + * \brief Select the number of layers associated to a subdetector. + */ +//TODO Possible improvement: reduce the number of switches in the code by implementing a map int PlotAlignmentValidation::numberOfLayers(int phase, int subdetector) { switch (phase) { case 0: @@ -146,6 +187,9 @@ int PlotAlignmentValidation::numberOfLayers(int phase, int subdetector) { } //------------------------------------------------------------------------------ +/*! \fn maxNumberOfLayers + * \brief Return the number of layers of a subdetector + */ int PlotAlignmentValidation::maxNumberOfLayers(int subdetector) { int result = 0; for (auto it = sourceList.begin(); it != sourceList.end(); ++it) { @@ -155,6 +199,9 @@ int PlotAlignmentValidation::maxNumberOfLayers(int subdetector) { } //------------------------------------------------------------------------------ +/*! \fn legendOptions + * \brief Assign legend options to members of the class + */ void PlotAlignmentValidation::legendOptions(TString options) { @@ -182,6 +229,9 @@ void PlotAlignmentValidation::legendOptions(TString options) } //------------------------------------------------------------------------------ +/*! \fn setOutputDir + * \brief Set the output direcotry + */ void PlotAlignmentValidation::setOutputDir( std::string dir ) { if (openedsummaryfile) { @@ -193,6 +243,9 @@ void PlotAlignmentValidation::setOutputDir( std::string dir ) } //------------------------------------------------------------------------------ +/*! \fn plotSubDetResiduals + * \brief Function used to plot residuals for a subdetector + */ void PlotAlignmentValidation::plotSubDetResiduals(bool plotNormHisto,unsigned int subDetId) { gStyle->SetOptStat(11111); @@ -415,6 +468,9 @@ void PlotAlignmentValidation::plotOutlierModules(const char *outputFileName, std } //------------------------------------------------------------------------------ +/*! \fn getTreeList + * \brief Extract from the rootfiles stored in the sourcelist the corresponding trees. + */ TList* PlotAlignmentValidation::getTreeList() { TList *treeList = new TList(); @@ -654,6 +710,9 @@ void PlotAlignmentValidation::plotSS( const std::string& options, const std::str //------------------------------------------------------------------------------ +/*! \fn plotDMR + * \brief Main function used to plot DMRs for a single IOV printing the canvases in the output directory and saving histograms and fit funtions in a root file. + */ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits, const std::string& options) { // If several, comma-separated values are given in 'variable', @@ -742,7 +801,7 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits std::cerr << "Unknown variable " << variable << std::endl; plotinfo.nbins = 100; plotinfo.min = -0.1; plotinfo.max = 0.1; } - + //Begin loop on structures for (int i=1; i<=6; ++i) { // Skip strip detectors if plotting any "Y" variable @@ -796,6 +855,16 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits openSummaryFile(); vmean.clear(); vrms.clear(); vdeltamean.clear(); vmeanerror.clear(); vPValueEqualSplitMeans.clear(), vAlignmentUncertainty.clear(); vPValueMeanEqualIdeal.clear(); vPValueRMSEqualIdeal.clear(); + std::string stringsubdet; + switch (i) { + case 1: stringsubdet = "BPIX"; break; + case 2: stringsubdet = "FPIX"; break; + case 3: stringsubdet = "TIB"; break; + case 4: stringsubdet = "TID"; break; + case 5: stringsubdet = "TOB"; break; + case 6: stringsubdet = "TEC"; break; + } + for(std::vector::iterator it = sourceList.begin(); it != sourceList.end(); ++it) { @@ -803,17 +872,19 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits plotinfo.h1 = plotinfo.h2 = plotinfo.h = 0; int minlayer = plotLayers ? 1 : plotLayerN; + //Layer 0 is associated to the entire structure, this check ensures that even when both the plotLayers and the plotPlain options are active, also the histogram for the entire structure is made. + if(plotinfo.plotPlain) minlayer=0; int maxlayer = plotLayers ? numberOfLayers(plotinfo.vars->getPhase(), plotinfo.subDetId) : plotLayerN; for (int layer = minlayer; layer <= maxlayer; layer++) { if (plotinfo.plotPlain) { - plotDMRHistogram(plotinfo, 0, layer); + plotDMRHistogram(plotinfo, 0, layer, stringsubdet); } if (plotinfo.plotSplits) { - plotDMRHistogram(plotinfo, -1, layer); - plotDMRHistogram(plotinfo, 1, layer); + plotDMRHistogram(plotinfo, -1, layer, stringsubdet); + plotDMRHistogram(plotinfo, 1, layer, stringsubdet); } if (plotinfo.plotPlain) { @@ -908,6 +979,7 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits else if (variable=="rmsNormX") plotName << "rmsNR_"; else if (variable=="rmsNormY") plotName << "rmsNYR_"; + TString subdet; switch (i) { case 1: subdet = "BPIX"; break; @@ -1051,7 +1123,6 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits summaryfile << "\n"; } } - } //------------------------------------------------------------------------------ @@ -1378,6 +1449,9 @@ THStack* PlotAlignmentValidation::addHists(const TString& selection, const TStri } //------------------------------------------------------------------------------ +/*! \fn fitGauss + * \brief Operate a Gaussian fit to the given histogram + */ TF1 * PlotAlignmentValidation::fitGauss(TH1 *hist,int color) { @@ -1388,9 +1462,9 @@ PlotAlignmentValidation::fitGauss(TH1 *hist,int color) float mean = hist->GetMean(); float sigma = hist->GetRMS(); - - - TF1 *func = new TF1("tmp", "gaus", mean - 2.*sigma, mean + 2.*sigma); + string functionname="gaussian_"; + functionname+=hist->GetName(); + TF1 *func = new TF1(functionname.c_str(), "gaus", mean - 2.*sigma, mean + 2.*sigma); func->SetLineColor(color); func->SetLineStyle(2); @@ -1407,12 +1481,23 @@ PlotAlignmentValidation::fitGauss(TH1 *hist,int color) } } } - - + storeHistogramInRootfile(hist,func); return func; } +//------------------------------------------------------------------------------ +/*! \fn storeHistogramInRootfile + * \brief Store the histogram and the gaussian function resulting from the fitGauss function into a root file + */ +void PlotAlignmentValidation::storeHistogramInRootfile(TH1* hist, TF1* func) +{ + //Store histogram and fit function in the root summary file + rootsummaryfile->cd(); + hist->Write(); + func->Write(); +} + //------------------------------------------------------------------------------ void PlotAlignmentValidation::scaleXaxis(TH1* hist, Int_t scale) { @@ -1483,6 +1568,9 @@ void PlotAlignmentValidation::setTitleStyle( TNamed &hist,const char* titleX, c //------------------------------------------------------------------------------ +/*! \fn + * \brief + */ void PlotAlignmentValidation::setHistStyle( TH1& hist,const char* titleX, const char* titleY, int color) { std::stringstream title_Xaxis; @@ -1539,7 +1627,6 @@ void PlotAlignmentValidation::setHistStyle( TH1& hist,const char* titleX, const } //------------------------------------------------------------------------------ - std::string PlotAlignmentValidation:: getSelectionForDMRPlot(int minHits, int subDetId, int direction, int layer) { @@ -1569,6 +1656,7 @@ getVariableForDMRPlot(const std::string& histoname, const std::string& variable, return builder.str(); } +//------------------------------------------------------------------------------ void PlotAlignmentValidation:: setDMRHistStyleAndLegend(TH1F* h, PlotAlignmentValidation::DMRPlotInfo& plotinfo, int direction, int layer) { @@ -1752,18 +1840,32 @@ setDMRHistStyleAndLegend(TH1F* h, PlotAlignmentValidation::DMRPlotInfo& plotinfo } +/*! + * \fn plotDMRHistogram + * \brief Create the DMR histrogram using data stored in trees and store them in the plotinfo structure. + */ + void PlotAlignmentValidation:: -plotDMRHistogram(PlotAlignmentValidation::DMRPlotInfo& plotinfo, int direction, int layer) +plotDMRHistogram(PlotAlignmentValidation::DMRPlotInfo& plotinfo, int direction, int layer, std::string subdet) { TH1F* h = 0; - std::string histoname; - if (direction == -1) { histoname = "myhisto1"; } - else if (direction == 1) { histoname = "myhisto2"; } - else { histoname = "myhisto"; } - std::string plotVariable = getVariableForDMRPlot(histoname, plotinfo.variable, plotinfo.nbins, plotinfo.min, plotinfo.max); + //Create a name for the histogram that summarize all relevant information: name of the geometry, variable plotted, structure, layer, and whether the modules considered point inward or outward. + TString histoname(plotinfo.vars->getName()); + histoname.ReplaceAll(" ","_"); + histoname+="_"; histoname+=subdet.c_str(); + if (plotinfo.variable == "medianY")histoname+="_y"; + if(layer!=0){ + if(subdet=="TID"||subdet=="TEC")histoname+="_disc"; + else histoname+="_layer"; + histoname+=to_string(layer); + } + if (direction == -1) { histoname += "_minus"; } + else if (direction == 1) { histoname += "_plus"; } + else { histoname += ""; } + std::string plotVariable = getVariableForDMRPlot(histoname.Data(), plotinfo.variable, plotinfo.nbins, plotinfo.min, plotinfo.max); std::string selection = getSelectionForDMRPlot(plotinfo.minHits, plotinfo.subDetId, direction, layer); plotinfo.vars->getTree()->Draw(plotVariable.c_str(), selection.c_str(), "goff"); - if (gDirectory) gDirectory->GetObject(histoname.c_str(), h); + if (gDirectory) gDirectory->GetObject(histoname.Data(), h); if (h && h->GetEntries() > 0) { if (direction == -1) { plotinfo.h1 = h; } else if (direction == 1) { plotinfo.h2 = h; } @@ -1870,8 +1972,6 @@ double PlotAlignmentValidation::resampleTestOfEqualRMS(TH1F* h1, TH1F* h2, int n - - //random variable: (\overline{X_1}-\mu_1)-(\overline{X_2}-\mu_2) //is centered approx around 0 //null hypothesis: \mu_1-\mu_2=0 @@ -1922,7 +2022,7 @@ float PlotAlignmentValidation::twotailedStudentTTestEqualMean(float t, float v){ return 2*(1-ROOT::Math::tdistribution_cdf(abs(t),v)); } -const TString PlotAlignmentValidation::summaryfilename = "OfflineValidationSummary.txt"; +const TString PlotAlignmentValidation::summaryfilename = "OfflineValidationSummary"; @@ -1938,7 +2038,7 @@ vector PlotAlignmentValidation::findmodule (TFile* f, unsigned int modul TkOffTreeVariables *variables=0; t->SetBranchAddress("TkOffTreeVariables", &variables); unsigned int number_of_entries=t->GetEntries(); - for (int i=0;iGetEntry(i); if (variables->moduleId==moduleid){ histnamex=variables->histNameX; diff --git a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h index cae3bcddca2ac..780a863870d4f 100644 --- a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h +++ b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h @@ -142,11 +142,13 @@ private : const static TString summaryfilename; ofstream summaryfile; bool openedsummaryfile = false; + TFile *rootsummaryfile; std::vector vmean, vdeltamean, vrms, vmeanerror, vPValueEqualSplitMeans, vPValueMeanEqualIdeal, vPValueRMSEqualIdeal, vAlignmentUncertainty; double resampleTestOfEqualMeans(TH1F* h1, TH1F* h2, int numSamples); double resampleTestOfEqualRMS(TH1F* h1, TH1F* h2, int numSamples); + void storeHistogramInRootfile(TH1* hist, TF1* func); TF1 *fitGauss(TH1 *hist,int color); //void plotBoxOverview(TCanvas &c1, TList &treeList,std::string plot_Var1a,std::string plot_Var1b, std::string plot_Var2, Int_t filenumber,Int_t minHits); //void plot1DDetailsSubDet(TCanvas &c1, TList &treeList, std::string plot_Var1a,std::string plot_Var1b, std::string plot_Var2, Int_t minHits); @@ -173,7 +175,7 @@ private : std::string getVariableForDMRPlot(const std::string& histoname, const std::string& variable, int nbins, double min, double max); void setDMRHistStyleAndLegend(TH1F* h, DMRPlotInfo& plotinfo, int direction = 0, int layer = 0); - void plotDMRHistogram(DMRPlotInfo& plotinfo, int direction = 0, int layer = 0); + void plotDMRHistogram(DMRPlotInfo& plotinfo, int direction = 0, int layer = 0, std::string subdet= ""); void modifySSHistAndLegend(THStack* hs, TLegend* legend); void openSummaryFile(); vector findmodule (TFile* f, unsigned int moduleid); diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py index 18088887d4160..bb1060df6b048 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/plottingOptions.py @@ -170,8 +170,6 @@ class PlottingOptionsZMuMu(BasePlottingOptions): "rebineta": "2", "rebinpt": "8", "AutoSetRange": "false", - "CustomMinY": "90.85", - "CustomMaxY": "91.5", } needpackages = {"MuonAnalysis/MomentumScaleCalibration"} validationclass = ZMuMuValidation diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py index f63caa054558c..c56b2afe05bfc 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/presentation.py @@ -186,8 +186,8 @@ def plotSortKey(plot): return 'chi2b' return plot -from . import geometryComparison -from . import offlineValidation -from . import trackSplittingValidation -from . import primaryVertexValidation -from . import zMuMuValidation +import Alignment.OfflineValidation.TkAlAllInOneTool.geometryComparison +import Alignment.OfflineValidation.TkAlAllInOneTool.offlineValidation +import Alignment.OfflineValidation.TkAlAllInOneTool.trackSplittingValidation +import Alignment.OfflineValidation.TkAlAllInOneTool.primaryVertexValidation +import Alignment.OfflineValidation.TkAlAllInOneTool.zMuMuValidation diff --git a/CalibCalorimetry/HcalPlugins/python/Hcal_Conditions_forGlobalTag_cff.py b/CalibCalorimetry/HcalPlugins/python/Hcal_Conditions_forGlobalTag_cff.py index c316df7be7697..328c10f97a69b 100644 --- a/CalibCalorimetry/HcalPlugins/python/Hcal_Conditions_forGlobalTag_cff.py +++ b/CalibCalorimetry/HcalPlugins/python/Hcal_Conditions_forGlobalTag_cff.py @@ -220,6 +220,8 @@ from Configuration.Eras.Modifier_run2_HEPlan1_2017_cff import run2_HEPlan1_2017 from Configuration.Eras.Modifier_run2_HCAL_2018_cff import run2_HCAL_2018 from Configuration.Eras.Modifier_run3_HB_cff import run3_HB +from Configuration.Eras.Modifier_phase2_hcal_cff import phase2_hcal +from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal run2_HCAL_2017.toModify( es_hardcode, useLayer0Weight = cms.bool(True), useIeta18depth1 = cms.bool(False) ) run2_HF_2017.toModify( es_hardcode, useHFUpgrade = cms.bool(True) ) @@ -228,9 +230,6 @@ run2_HCAL_2018.toModify( es_hardcode, useLayer0Weight = cms.bool(True), useIeta18depth1 = cms.bool(False) ) run3_HB.toModify( es_hardcode, useHBUpgrade = cms.bool(True), HBreCalibCutoff = cms.double(100.0) ) -# now that we have an emap -run3_HB.toModify( es_hardcode, toGet = cms.untracked.vstring(_toGet_noEmap), ) -from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal +phase2_hcal.toModify( es_hardcode, toGet = cms.untracked.vstring(_toGet_noEmap)) phase2_hgcal.toModify( es_hardcode, killHE = cms.bool(True) ) - diff --git a/CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml b/CalibPPS/ESProducers/plugins/BuildFile.xml similarity index 71% rename from CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml rename to CalibPPS/ESProducers/plugins/BuildFile.xml index 9996ffa1f52d8..4518b0b24e320 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/BuildFile.xml +++ b/CalibPPS/ESProducers/plugins/BuildFile.xml @@ -1,9 +1,9 @@ - + - + diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSAlignmentInfo.cc b/CalibPPS/ESProducers/plugins/CTPPSAlignmentInfo.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSAlignmentInfo.cc rename to CalibPPS/ESProducers/plugins/CTPPSAlignmentInfo.cc diff --git a/CalibPPS/ESProducers/plugins/CTPPSBeamParametersESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSBeamParametersESSource.cc new file mode 100644 index 0000000000000..adb4f868049b2 --- /dev/null +++ b/CalibPPS/ESProducers/plugins/CTPPSBeamParametersESSource.cc @@ -0,0 +1,238 @@ +/**************************************************************************** + * + * CondFormats/CTPPSReadoutObjects/plugins/CTPPSBeamParametersESSource.cc + * + * Description : - Loads CTPPSBeamParameters from the CTPPSBeamParametersESSource_cfi.py + * config file. + * - Currently, one single set of beam parameters is provided. Just to be + * ready in time for 10_4_0 and allow simple tests. + * - To be further developed to provide multiple sets of parameters + * - Needed while CTPPSBeamParameters is not available in database + * + * + * Author: + * Wagner Carvalho wcarvalh@cern.ch + * + ****************************************************************************/ + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ModuleFactory.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +using namespace std; + +/** + * \brief Loads CTPPSBeamParameters from a config file. + **/ + +class CTPPSBeamParametersESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ +public: + + CTPPSBeamParametersESSource(const edm::ParameterSet&); + ~CTPPSBeamParametersESSource() override = default; + + std::unique_ptr produce(const CTPPSBeamParametersRcd&); + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + + bool setBeamPars_; + + /// Set BP to their values from config + void setBeamParameters(const edm::ParameterSet &); + /// Fill CTPPSBeamParameters object with BP + std::unique_ptr fillBeamParameters(); + + // Beam parameters + double beamMom45_, beamMom56_; + double betaStarX45_, betaStarY45_, betaStarX56_, betaStarY56_; + double beamDivX45_, beamDivY45_, beamDivX56_, beamDivY56_; + double halfXangleX45_, halfXangleY45_; + double halfXangleX56_, halfXangleY56_; + double vtxOffsetX45_, vtxOffsetY45_, vtxOffsetZ45_; + double vtxOffsetX56_, vtxOffsetY56_, vtxOffsetZ56_; + double vtxStddevX_, vtxStddevY_, vtxStddevZ_; + +protected: + +/// sets infinite validity of this data + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSBeamParametersESSource::CTPPSBeamParametersESSource(const edm::ParameterSet& iConfig) : + setBeamPars_( iConfig.getParameter( "setBeamPars" ) ), + beamMom45_( 0. ), beamMom56_( 0. ), + betaStarX45_( 0. ), betaStarY45_( 0. ), betaStarX56_( 0. ), betaStarY56_( 0. ), + beamDivX45_( 0. ), beamDivY45_( 0. ), beamDivX56_( 0. ), beamDivY56_( 0. ), + halfXangleX45_( 0. ), halfXangleY45_( 0. ), + halfXangleX56_( 0. ), halfXangleY56_( 0. ), + vtxOffsetX45_( 0. ), vtxOffsetY45_( 0. ), vtxOffsetZ45_( 0. ), + vtxOffsetX56_( 0. ), vtxOffsetY56_( 0. ), vtxOffsetZ56_( 0. ), + vtxStddevX_( 0. ), vtxStddevY_( 0. ), vtxStddevZ_( 0. ) +{ + if ( setBeamPars_ ) + setBeamParameters( iConfig ); + + setWhatProduced(this); + findingRecord(); +} + +//---------------------------------------------------------------------------------------------------- + +std::unique_ptr +CTPPSBeamParametersESSource::produce( const CTPPSBeamParametersRcd & ) +{ + // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object + auto bp = ( setBeamPars_ ) + ? fillBeamParameters() + : std::make_unique(); + + edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp; + + return bp; +} + +//---------------------------------------------------------------------------------------------------- + +void +CTPPSBeamParametersESSource::setBeamParameters( const edm::ParameterSet& iConfig ) +{ + beamMom45_ = iConfig.getParameter( "beamMom45" ); + beamMom56_ = iConfig.getParameter( "beamMom56" ); + betaStarX45_ = iConfig.getParameter( "betaStarX45" ); + betaStarX56_ = iConfig.getParameter( "betaStarX56" ); + betaStarY45_ = iConfig.getParameter( "betaStarY45" ); + betaStarY56_ = iConfig.getParameter( "betaStarY56" ); + beamDivX45_ = iConfig.getParameter( "beamDivX45" ); + beamDivX56_ = iConfig.getParameter( "beamDivX56" ); + beamDivY45_ = iConfig.getParameter( "beamDivY45" ); + beamDivY56_ = iConfig.getParameter( "beamDivY56" ); + halfXangleX45_ = iConfig.getParameter( "halfXangleX45" ); + halfXangleX56_ = iConfig.getParameter( "halfXangleX56" ); + halfXangleY45_ = iConfig.getParameter( "halfXangleY45" ); + halfXangleY56_ = iConfig.getParameter( "halfXangleY56" ); + vtxOffsetX45_ = iConfig.getParameter( "vtxOffsetX45" ); + vtxOffsetY45_ = iConfig.getParameter( "vtxOffsetY45" ); + vtxOffsetZ45_ = iConfig.getParameter( "vtxOffsetZ45" ); + vtxOffsetX56_ = iConfig.getParameter( "vtxOffsetX56" ); + vtxOffsetY56_ = iConfig.getParameter( "vtxOffsetY56" ); + vtxOffsetZ56_ = iConfig.getParameter( "vtxOffsetZ56" ); + vtxStddevX_ = iConfig.getParameter( "vtxStddevX" ); + vtxStddevY_ = iConfig.getParameter( "vtxStddevY" ); + vtxStddevZ_ = iConfig.getParameter( "vtxStddevZ" ); +} + +//---------------------------------------------------------------------------------------------------- + +std::unique_ptr +CTPPSBeamParametersESSource::fillBeamParameters() +{ + auto p = std::make_unique(); + + p->setBeamMom45( beamMom45_ ); + p->setBeamMom56( beamMom56_ ); + + p->setBetaStarX45( betaStarX45_ ); + p->setBetaStarY45( betaStarY45_ ); + p->setBetaStarX56( betaStarX56_ ); + p->setBetaStarY56( betaStarY56_ ); + + p->setBeamDivergenceX45( beamDivX45_ ); + p->setBeamDivergenceY45( beamDivY45_ ); + p->setBeamDivergenceX56( beamDivX56_ ); + p->setBeamDivergenceY56( beamDivY56_ ); + + p->setHalfXangleX45( halfXangleX45_ ); + p->setHalfXangleY45( halfXangleY45_ ); + p->setHalfXangleX56( halfXangleX56_ ); + p->setHalfXangleY56( halfXangleY56_ ); + + p->setVtxOffsetX45( vtxOffsetX45_ ); + p->setVtxOffsetY45( vtxOffsetY45_ ); + p->setVtxOffsetZ45( vtxOffsetZ45_ ); + p->setVtxOffsetX56( vtxOffsetX56_ ); + p->setVtxOffsetY56( vtxOffsetY56_ ); + p->setVtxOffsetZ56( vtxOffsetZ56_ ); + + p->setVtxStddevX( vtxStddevX_ ); + p->setVtxStddevY( vtxStddevY_ ); + p->setVtxStddevZ( vtxStddevZ_ ); + + return p; +} + +//---------------------------------------------------------------------------------------------------- + +void +CTPPSBeamParametersESSource::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity ) +{ + edm::LogInfo("CTPPSBeamParametersESSource") + << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n" + << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event(); + + edm::ValidityInterval infinity( iosv.beginOfTime(), iosv.endOfTime() ); + oValidity = infinity; +} + +//---------------------------------------------------------------------------------------------------- + +void +CTPPSBeamParametersESSource::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) +{ + edm::ParameterSetDescription desc; + desc.add( "setBeamPars", true ); + // beam momentum (GeV) + desc.add( "beamMom45", 6500. ); + desc.add( "beamMom56", 6500. ); + // beta* (cm) + desc.add( "betaStarX45", 30. ); + desc.add( "betaStarY45", 30. ); + desc.add( "betaStarX56", 30. ); + desc.add( "betaStarY56", 30. ); + // beam divergence (rad) + desc.add( "beamDivX45", 0.1 ); + desc.add( "beamDivY45", 0.1 ); + desc.add( "beamDivX56", 0.1 ); + desc.add( "beamDivY56", 0.1 ); + // half crossing angle (rad) + desc.add( "halfXangleX45", 80.e-6 ); + desc.add( "halfXangleY45", 80.e-6 ); + desc.add( "halfXangleX56", 80.e-6 ); + desc.add( "halfXangleY56", 80.e-6 ); + // vertex offset (cm) + desc.add( "vtxOffsetX45", 1.e-2 ); + desc.add( "vtxOffsetY45", 1.e-2 ); + desc.add( "vtxOffsetZ45", 1.e-2 ); + desc.add( "vtxOffsetX56", 1.e-2 ); + desc.add( "vtxOffsetY56", 1.e-2 ); + desc.add( "vtxOffsetZ56", 1.e-2 ); + // vertex sigma (cm) + desc.add( "vtxStddevX", 2.e-2 ); + desc.add( "vtxStddevY", 2.e-2 ); + desc.add( "vtxStddevZ", 2.e-2 ); + + descriptions.add( "ctppsBeamParametersESSource", desc ); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE( CTPPSBeamParametersESSource ); + diff --git a/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc new file mode 100644 index 0000000000000..d4db89148683a --- /dev/null +++ b/CalibPPS/ESProducers/plugins/CTPPSInterpolatedOpticalFunctionsESSource.cc @@ -0,0 +1,206 @@ +// authors: Jan Kaspar (jan.kaspar@gmail.com) + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + + +class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer +{ + public: + CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet&); + ~CTPPSInterpolatedOpticalFunctionsESSource() override {} + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + + std::shared_ptr produce(const CTPPSInterpolatedOpticsRcd&); + + private: + std::string lhcInfoLabel_; + + float currentCrossingAngle_; + bool currentDataValid_; + std::shared_ptr currentData_; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSource(const edm::ParameterSet& iConfig) : + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), + currentCrossingAngle_(-1.), + currentDataValid_(false) +{ + setWhatProduced(this, &CTPPSInterpolatedOpticalFunctionsESSource::produce); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSInterpolatedOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions &descriptions) +{ + edm::ParameterSetDescription desc; + + desc.add("lhcInfoLabel", "") + ->setComment("label of the LHCInfo record"); + + descriptions.add("ctppsInterpolatedOpticalFunctionsESSource", desc); +} + +//---------------------------------------------------------------------------------------------------- + +std::shared_ptr CTPPSInterpolatedOpticalFunctionsESSource::produce(const CTPPSInterpolatedOpticsRcd& iRecord) +{ + // get the input data + edm::ESHandle hOFColl; + iRecord.getRecord().get(hOFColl); + + edm::ESHandle hLHCInfo; + iRecord.getRecord().get(lhcInfoLabel_, hLHCInfo); + + // is there anything to do? + if (currentDataValid_ && hLHCInfo->crossingAngle() == currentCrossingAngle_) + return currentData_; + + // is crossing angle reasonable (LHCInfo is correctly filled in DB)? + if (currentCrossingAngle_ == 0.) + { + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Invalid crossing angle, no optical functions produced."; + + currentDataValid_ = false; + currentData_ = std::make_shared(); + + return currentData_; + } + + // set new crossing angle + currentCrossingAngle_ = hLHCInfo->crossingAngle(); + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "Crossing angle has changed to " << currentCrossingAngle_ << "."; + + // is input optics available ? + if (hOFColl->empty()) + { + edm::LogInfo("CTPPSInterpolatedOpticalFunctionsESSource") << "No input optics available, no optical functions produced."; + + currentDataValid_ = false; + currentData_ = std::make_shared(); + + return currentData_; + } + + // regular case with single-xangle input + if (hOFColl->size() == 1) + { + const auto &it = hOFColl->begin(); + + // does the input xangle correspond to the actual one? + if (fabs(currentCrossingAngle_ - it->first) > 1e-6) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Cannot interpolate: input given only for xangle " + << it->first << " while interpolation requested for " << currentCrossingAngle_ << "."; + + currentData_ = std::make_shared(); + for (const auto &rp_p : it->second) + { + const auto rpId = rp_p.first; + LHCInterpolatedOpticalFunctionsSet iof(rp_p.second); + iof.initializeSplines(); + currentData_->emplace(rpId, std::move(iof)); + } + + currentDataValid_ = true; + } + + // regular case with multi-xangle input + if (hOFColl->size() > 1) + { + // find the closest xangle points for interpolation + auto it1 = hOFColl->begin(); + auto it2 = std::next(it1); + + if (currentCrossingAngle_ > it1->first) + { + for (; it1 != hOFColl->end(); ++it1) + { + it2 = std::next(it1); + + if (it2 == hOFColl->end()) + { + it2 = it1; + it1 = std::prev(it1); + break; + } + + if (it1->first <= currentCrossingAngle_ && currentCrossingAngle_ < it2->first) + break; + } + } + + const auto &xangle1 = it1->first; + const auto &xangle2 = it2->first; + + const auto &ofs1 = it1->second; + const auto &ofs2 = it2->second; + + // do the interpoaltion RP by RP + currentData_ = std::make_shared(); + for (const auto &rp_p : ofs1) + { + const auto rpId = rp_p.first; + const auto &rp_it2 = ofs2.find(rpId); + if (rp_it2 == ofs2.end()) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Mismatch between ofs1 and ofs2."; + + const auto &of1 = rp_p.second; + const auto &of2 = rp_it2->second; + + LHCInterpolatedOpticalFunctionsSet iof; + iof.m_z = of1.getScoringPlaneZ(); + + const size_t num_xi_vals = of1.getXiValues().size(); + + iof.m_xi_values.resize(num_xi_vals); + + for (size_t fi = 0; fi < of1.getFcnValues().size(); ++fi) + { + iof.m_fcn_values[fi].resize(num_xi_vals); + + for (size_t pi = 0; pi < num_xi_vals; ++pi) + { + double xi = of1.getXiValues()[pi]; + double xi_control = of2.getXiValues()[pi]; + + if (fabs(xi - xi_control) > 1e-6) + throw cms::Exception("CTPPSInterpolatedOpticalFunctionsESSource") << "Xi mismatch between ofs1 and ofs2."; + + iof.m_xi_values[pi] = xi; + + double v1 = of1.getFcnValues()[fi][pi]; + double v2 = of2.getFcnValues()[fi][pi]; + iof.m_fcn_values[fi][pi] = v1 + (v2 - v1) / (xangle2 - xangle1) * (currentCrossingAngle_ - xangle1); + } + } + + iof.initializeSplines(); + + currentDataValid_ = true; + currentData_->emplace(rpId, std::move(iof)); + } + } + + return currentData_; +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_MODULE(CTPPSInterpolatedOpticalFunctionsESSource); diff --git a/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc new file mode 100644 index 0000000000000..4898db7933e78 --- /dev/null +++ b/CalibPPS/ESProducers/plugins/CTPPSLHCInfoESSource.cc @@ -0,0 +1,110 @@ +// Original Author: Jan Kašpar + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +//---------------------------------------------------------------------------------------------------- + +/** + * \brief Provides LHCInfo data necessary for CTPPS reconstruction (and direct simulation). + **/ +class CTPPSLHCInfoESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ + public: + CTPPSLHCInfoESSource(const edm::ParameterSet &); + edm::ESProducts> produce(const LHCInfoRcd &); + + private: + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + + std::string m_label; + + edm::EventRange m_validityRange; + double m_beamEnergy; + double m_xangle; + + bool m_insideValidityRange; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSLHCInfoESSource::CTPPSLHCInfoESSource(const edm::ParameterSet& conf) : + m_label(conf.getParameter("label")), + m_validityRange(conf.getParameter("validityRange")), + m_beamEnergy(conf.getParameter("beamEnergy")), + m_xangle(conf.getParameter("xangle")), + m_insideValidityRange(false) +{ + setWhatProduced(this, m_label); + findingRecord(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSLHCInfoESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +{ + // TODO: the IOV specified in config is temporarily replaced with a hardcoded one + m_insideValidityRange = true; + + edm::IOVSyncValue beg(edm::EventID(270293, 0, 0), edm::Timestamp(1461016800ULL << 32)); + edm::IOVSyncValue end(edm::EventID(290872, 0, 0), edm::Timestamp(1483138800ULL << 32)); + oValidity = edm::ValidityInterval(beg, end); + + /* + if (edm::contains(m_validityRange, iosv.eventID())) + { + m_insideValidityRange = true; + oValidity = edm::ValidityInterval(edm::IOVSyncValue(m_validityRange.startEventID()), edm::IOVSyncValue(m_validityRange.endEventID())); + } else { + m_insideValidityRange = false; + + if (iosv.eventID() < m_validityRange.startEventID()) + { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID endEvent = (lb > 1) ? edm::EventID(run, lb-1, 0) : edm::EventID(run-1, edm::EventID::maxLuminosityBlockNumber(), 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(endEvent)); + } else { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber()-1) ? edm::EventID(run, lb+1, 0) : edm::EventID(run+1, 0, 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); + } + } + */ +} + +//---------------------------------------------------------------------------------------------------- + +edm::ESProducts> CTPPSLHCInfoESSource::produce(const LHCInfoRcd &) +{ + auto output = std::make_unique(); + + if (m_insideValidityRange) + { + output->setEnergy(m_beamEnergy); + output->setCrossingAngle(m_xangle); + } else { + output->setEnergy(0.); + output->setCrossingAngle(0.); + } + + return edm::es::products(std::move(output)); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSLHCInfoESSource); + diff --git a/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc new file mode 100644 index 0000000000000..cf1d7f4c28cc8 --- /dev/null +++ b/CalibPPS/ESProducers/plugins/CTPPSOpticalFunctionsESSource.cc @@ -0,0 +1,161 @@ +// Original Author: Jan Kašpar + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/SourceFactory.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" +#include "FWCore/Framework/interface/ESProducts.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" + +//---------------------------------------------------------------------------------------------------- + +/** + * \brief Loads optical functions from ROOT files. + **/ +class CTPPSOpticalFunctionsESSource: public edm::ESProducer, public edm::EventSetupRecordIntervalFinder +{ + public: + CTPPSOpticalFunctionsESSource(const edm::ParameterSet &); + ~CTPPSOpticalFunctionsESSource() override = default; + + edm::ESProducts> produce(const CTPPSOpticsRcd &); + static void fillDescriptions(edm::ConfigurationDescriptions&); + + private: + void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override; + + edm::EventRange m_validityRange; + bool m_insideValidityRange; + + struct FileInfo + { + double xangle; + std::string fileName; + }; + std::vector m_fileInfo; + + struct RPInfo + { + std::string dirName; + double scoringPlaneZ; + }; + std::unordered_map m_rpInfo; +}; + +//---------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------- + +CTPPSOpticalFunctionsESSource::CTPPSOpticalFunctionsESSource(const edm::ParameterSet& conf) : + m_validityRange(conf.getParameter("validityRange")), + m_insideValidityRange(false) +{ + for (const auto &pset : conf.getParameter>("opticalFunctions")) + { + const double &xangle = pset.getParameter("xangle"); + const std::string &fileName = pset.getParameter("fileName").fullPath(); + m_fileInfo.push_back({xangle, fileName}); + } + + for (const auto &pset : conf.getParameter>("scoringPlanes")) + { + const unsigned int rpId = pset.getParameter("rpId"); + const std::string dirName = pset.getParameter("dirName"); + const double z = pset.getParameter("z"); + const RPInfo entry = {dirName, z}; + m_rpInfo.emplace(rpId, entry); + } + + setWhatProduced(this); + findingRecord(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSOpticalFunctionsESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, + const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity) +{ + if (edm::contains(m_validityRange, iosv.eventID())) + { + m_insideValidityRange = true; + oValidity = edm::ValidityInterval(edm::IOVSyncValue(m_validityRange.startEventID()), edm::IOVSyncValue(m_validityRange.endEventID())); + } else { + m_insideValidityRange = false; + + if (iosv.eventID() < m_validityRange.startEventID()) + { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID endEvent = (lb > 1) ? edm::EventID(run, lb-1, 0) : edm::EventID(run-1, edm::EventID::maxLuminosityBlockNumber(), 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue(endEvent)); + } else { + edm::RunNumber_t run = m_validityRange.startEventID().run(); + edm::LuminosityBlockNumber_t lb = m_validityRange.startEventID().luminosityBlock(); + edm::EventID beginEvent = (lb < edm::EventID::maxLuminosityBlockNumber()-1) ? edm::EventID(run, lb+1, 0) : edm::EventID(run+1, 0, 0); + + oValidity = edm::ValidityInterval(edm::IOVSyncValue(beginEvent), edm::IOVSyncValue::endOfTime()); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +edm::ESProducts > +CTPPSOpticalFunctionsESSource::produce(const CTPPSOpticsRcd &) +{ + // fill the output + auto output = std::make_unique(); + + if (m_insideValidityRange) + { + for (const auto &fi : m_fileInfo) + { + std::unordered_map xa_data; + + for (const auto &rpi : m_rpInfo) + { + LHCOpticalFunctionsSet fcn(fi.fileName, rpi.second.dirName, rpi.second.scoringPlaneZ); + xa_data.emplace(rpi.first, std::move(fcn)); + } + + output->emplace(fi.xangle, xa_data); + } + } + + // commit the output + return edm::es::products(std::move(output)); +} + +//---------------------------------------------------------------------------------------------------- + +void +CTPPSOpticalFunctionsESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + + desc.add("validityRange", edm::EventRange())->setComment("interval of validity"); + + edm::ParameterSetDescription of_desc; + of_desc.add("xangle")->setComment("half crossing angle value in urad"); + of_desc.add("fileName")->setComment("ROOT file with optical functions"); + std::vector of; + desc.addVPSet("opticalFunctions", of_desc, of)->setComment("list of optical functions at different crossing angles"); + + edm::ParameterSetDescription sp_desc; + sp_desc.add("rpId")->setComment("associated detector DetId"); + sp_desc.add("dirName")->setComment("associated path to the optical functions file"); + sp_desc.add("z")->setComment("longitudinal position at scoring plane/detector"); + std::vector sp; + desc.addVPSet("scoringPlanes", sp_desc, sp)->setComment("list of sensitive planes/detectors stations"); + + descriptions.add("ctppsOpticalFunctionsESSource", desc); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_EVENTSETUP_SOURCE(CTPPSOpticalFunctionsESSource); + diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSPixelDAQMappingESSourceXML.cc b/CalibPPS/ESProducers/plugins/CTPPSPixelDAQMappingESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSPixelDAQMappingESSourceXML.cc rename to CalibPPS/ESProducers/plugins/CTPPSPixelDAQMappingESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc b/CalibPPS/ESProducers/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc rename to CalibPPS/ESProducers/plugins/CTPPSRPAlignmentCorrectionsDataESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/PPSTimingCalibrationESSource.cc b/CalibPPS/ESProducers/plugins/PPSTimingCalibrationESSource.cc similarity index 57% rename from CondFormats/CTPPSReadoutObjects/plugins/PPSTimingCalibrationESSource.cc rename to CalibPPS/ESProducers/plugins/PPSTimingCalibrationESSource.cc index d12b0cbbfd405..2ffe317dfd180 100644 --- a/CondFormats/CTPPSReadoutObjects/plugins/PPSTimingCalibrationESSource.cc +++ b/CalibPPS/ESProducers/plugins/PPSTimingCalibrationESSource.cc @@ -2,6 +2,7 @@ * * This is a part of CTPPS offline software. * Authors: + * Edoardo Bossini * Filip Dej * Laurent Forthomme * @@ -34,25 +35,35 @@ class PPSTimingCalibrationESSource : public edm::ESProducer, public edm::EventSe { public: PPSTimingCalibrationESSource( const edm::ParameterSet& ); - ~PPSTimingCalibrationESSource() override = default; edm::ESProducts > produce( const PPSTimingCalibrationRcd& ); static void fillDescriptions( edm::ConfigurationDescriptions& ); private: + enum struct DetectorType + { + INVALID = 0, + TOTEM_UFSD = 1, + PPS_DIAMOND = 2 + }; + void setIntervalFor( const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval& ) override; - /// Extract calibration data from JSON file - std::unique_ptr parseJsonFile() const; + /// Extract calibration data from JSON file (TOTEM vertical) + std::unique_ptr parseTotemUFSDJsonFile() const; + /// Extract calibration data from JSON file (PPS horizontal diamond) + std::unique_ptr parsePPSDiamondJsonFile() const; const std::string filename_; + DetectorType subdetector_; }; //------------------------------------------------------------------------------ PPSTimingCalibrationESSource::PPSTimingCalibrationESSource( const edm::ParameterSet& iConfig ) : - filename_( iConfig.getParameter( "calibrationFile" ).fullPath() ) + filename_ ( iConfig.getParameter( "calibrationFile" ).fullPath() ), + subdetector_( (DetectorType)iConfig.getParameter( "subDetector" ) ) { setWhatProduced( this ); findingRecord(); @@ -63,7 +74,15 @@ PPSTimingCalibrationESSource::PPSTimingCalibrationESSource( const edm::Parameter edm::ESProducts > PPSTimingCalibrationESSource::produce( const PPSTimingCalibrationRcd& ) { - return edm::es::products( parseJsonFile() ); + switch ( subdetector_ ) { + case DetectorType::TOTEM_UFSD: + return edm::es::products( parseTotemUFSDJsonFile() ); + case DetectorType::PPS_DIAMOND: + return edm::es::products( parsePPSDiamondJsonFile() ); + default: + throw cms::Exception( "PPSTimingCalibrationESSource" ) + << "Subdetector " << (int)subdetector_ << " not recognised!"; + } } //------------------------------------------------------------------------------ @@ -79,20 +98,20 @@ PPSTimingCalibrationESSource::setIntervalFor( const edm::eventsetup::EventSetupR //------------------------------------------------------------------------------ std::unique_ptr -PPSTimingCalibrationESSource::parseJsonFile() const +PPSTimingCalibrationESSource::parseTotemUFSDJsonFile() const { - pt::ptree node; - pt::read_json( filename_, node ); + pt::ptree mother_node; + pt::read_json( filename_, mother_node ); - const std::string formula = node.get( "formula" ); + const std::string formula = mother_node.get( "formula" ); PPSTimingCalibration::ParametersMap params; PPSTimingCalibration::TimingMap time_info; - for ( pt::ptree::value_type& par : node.get_child( "parameters" ) ) { + for ( pt::ptree::value_type& par : mother_node.get_child( "parameters" ) ) { PPSTimingCalibration::Key key; key.db = (int)strtol( par.first.data(), nullptr, 10 ); - for (pt::ptree::value_type &board : par.second) { + for ( pt::ptree::value_type& board : par.second ) { key.sampic = board.second.get( "sampic" ); key.channel = board.second.get( "channel" ); double timeOffset = board.second.get( "time_offset" ); @@ -101,7 +120,7 @@ PPSTimingCalibrationESSource::parseJsonFile() const time_info[key] = { timeOffset, timePrecision }; int cell_ct = 0; - for ( pt::ptree::value_type &cell : board.second.get_child( "cells" ) ) { + for ( pt::ptree::value_type& cell : board.second.get_child( "cells" ) ) { std::vector values; key.cell = cell_ct; @@ -115,12 +134,51 @@ PPSTimingCalibrationESSource::parseJsonFile() const return std::make_unique( formula, params, time_info ); } +std::unique_ptr +PPSTimingCalibrationESSource::parsePPSDiamondJsonFile() const +{ + pt::ptree mother_node; + pt::read_json( filename_, mother_node ); + + const std::string formula = mother_node.get( "formula" ); + PPSTimingCalibration::ParametersMap params; + PPSTimingCalibration::TimingMap time_info; + + for ( pt::ptree::value_type& par : mother_node.get_child( "Parameters.Sectors" ) ) { + PPSTimingCalibration::Key key; + key.db = par.second.get( "sector" ); + + for ( pt::ptree::value_type& st : par.second.get_child( "Stations" ) ) { + key.sampic = st.second.get( "station" ); + + for ( pt::ptree::value_type& pl : st.second.get_child( "Planes" ) ) { + key.channel = pl.second.get( "plane" ); + + for ( pt::ptree::value_type& ch : pl.second.get_child( "Channels" ) ) { + key.cell = ch.second.get( "channel" ); + double timeOffset = ch.second.get( "time_offset" ); + double timePrecision = ch.second.get( "time_precision" ); + time_info[key] = { timeOffset, timePrecision }; + + std::vector values; + for ( pt::ptree::value_type& param : ch.second.get_child( "param" ) ) + values.emplace_back( std::stod( param.second.data(), nullptr ) ); + params[key] = values; + } + } + } + } + return std::make_unique( formula, params, time_info ); +} + void PPSTimingCalibrationESSource::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) { edm::ParameterSetDescription desc; desc.add( "calibrationFile", edm::FileInPath() ) ->setComment( "file with SAMPIC calibrations, ADC and INL; if empty or corrupted, no calibration will be applied" ); + desc.add( "subDetector", (unsigned int)PPSTimingCalibrationESSource::DetectorType::INVALID ) + ->setComment( "type of sub-detector for which the calibrations are provided" ); descriptions.add( "ppsTimingCalibrationESSource", desc ); } diff --git a/CondFormats/CTPPSReadoutObjects/plugins/PrintTotemDAQMapping.cc b/CalibPPS/ESProducers/plugins/PrintTotemDAQMapping.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/PrintTotemDAQMapping.cc rename to CalibPPS/ESProducers/plugins/PrintTotemDAQMapping.cc diff --git a/CondFormats/CTPPSReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc b/CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/plugins/TotemDAQMappingESSourceXML.cc rename to CalibPPS/ESProducers/plugins/TotemDAQMappingESSourceXML.cc diff --git a/CondFormats/CTPPSReadoutObjects/python/CTPPSPixelDAQMappingESSourceXML_cfi.py b/CalibPPS/ESProducers/python/CTPPSPixelDAQMappingESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/CTPPSPixelDAQMappingESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/CTPPSPixelDAQMappingESSourceXML_cfi.py diff --git a/CalibPPS/ESProducers/python/ctppsAlignment_cff.py b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py new file mode 100644 index 0000000000000..fc2aed2fb1a3d --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsAlignment_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +from CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi import * +ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring( + "Alignment/CTPPS/data/RPixGeometryCorrections.xml" +) diff --git a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py new file mode 100644 index 0000000000000..f7ecf58fd6561 --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py @@ -0,0 +1,11 @@ +import FWCore.ParameterSet.Config as cms + +ctppsLHCInfoLabel = cms.string("ctpps_minimal") + +# minimal LHCInfo for 2016 data +ctppsLHCInfoESSource_2016 = cms.ESSource("CTPPSLHCInfoESSource", + label = ctppsLHCInfoLabel, + validityRange = cms.EventRange("270293:min - 290872:max"), + beamEnergy = cms.double(6500), # GeV + xangle = cms.double(185) # murad +) diff --git a/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py new file mode 100644 index 0000000000000..5a6068db262c4 --- /dev/null +++ b/CalibPPS/ESProducers/python/ctppsOpticalFunctions_cff.py @@ -0,0 +1,26 @@ +import FWCore.ParameterSet.Config as cms + +from CalibPPS.ESProducers.ctppsLHCInfo_cff import * + +from CalibPPS.ESProducers.ctppsOpticalFunctionsESSource_cfi import ctppsOpticalFunctionsESSource as _optics_tmp + +# optical functions for 2016 data +ctppsOpticalFunctionsESSource_2016 = _optics_tmp.clone( + validityRange = cms.EventRange("270293:min - 290872:max"), + + opticalFunctions = cms.VPSet( + cms.PSet( xangle = cms.double(185), fileName = cms.FileInPath("CalibPPS/ESProducers/data/optical_functions_2016.root") ) + ), + + scoringPlanes = cms.VPSet( + # z in cm + cms.PSet( rpId = cms.uint32(0x76100000), dirName = cms.string("XRPH_C6L5_B2"), z = cms.double(-20382.6) ), # RP 002 + cms.PSet( rpId = cms.uint32(0x76180000), dirName = cms.string("XRPH_D6L5_B2"), z = cms.double(-21255.1) ), # RP 003 + cms.PSet( rpId = cms.uint32(0x77100000), dirName = cms.string("XRPH_C6R5_B1"), z = cms.double(+20382.6) ), # RP 102 + cms.PSet( rpId = cms.uint32(0x77180000), dirName = cms.string("XRPH_D6R5_B1"), z = cms.double(+21255.1) ), # RP 103 + ) +) + +# optics interpolation between crossing angles +from CalibPPS.ESProducers.ctppsInterpolatedOpticalFunctionsESSource_cfi import * +ctppsInterpolatedOpticalFunctionsESSource.lhcInfoLabel = ctppsLHCInfoLabel diff --git a/CondFormats/CTPPSReadoutObjects/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py b/CalibPPS/ESProducers/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/ctppsRPAlignmentCorrectionsDataESSourceXML_cfi.py diff --git a/CondFormats/CTPPSReadoutObjects/python/totemDAQMappingESSourceXML_cfi.py b/CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/python/totemDAQMappingESSourceXML_cfi.py rename to CalibPPS/ESProducers/python/totemDAQMappingESSourceXML_cfi.py diff --git a/CalibPPS/ESProducers/test/BuildFile.xml b/CalibPPS/ESProducers/test/BuildFile.xml new file mode 100644 index 0000000000000..b42ccdba69631 --- /dev/null +++ b/CalibPPS/ESProducers/test/BuildFile.xml @@ -0,0 +1,3 @@ + + + diff --git a/CondFormats/CTPPSReadoutObjects/test/alignment_xml_io_test.cc b/CalibPPS/ESProducers/test/alignment_xml_io_test.cc similarity index 100% rename from CondFormats/CTPPSReadoutObjects/test/alignment_xml_io_test.cc rename to CalibPPS/ESProducers/test/alignment_xml_io_test.cc diff --git a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_DB_cfg.py b/CalibPPS/ESProducers/test/print_alignment_info_DB_cfg.py similarity index 100% rename from CondFormats/CTPPSReadoutObjects/test/print_alignment_info_DB_cfg.py rename to CalibPPS/ESProducers/test/print_alignment_info_DB_cfg.py diff --git a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py b/CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py similarity index 92% rename from CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py rename to CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py index 5b3648db23537..064ab1ff60f2b 100644 --- a/CondFormats/CTPPSReadoutObjects/test/print_alignment_info_XML_cfg.py +++ b/CalibPPS/ESProducers/test/print_alignment_info_XML_cfg.py @@ -11,7 +11,7 @@ ) # load alignment corrections -process.load("CondFormats.CTPPSReadoutObjects.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") +process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") process.ctppsRPAlignmentCorrectionsDataESSourceXML.RealFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") process.ctppsRPAlignmentCorrectionsDataESSourceXML.MeasuredFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") process.ctppsRPAlignmentCorrectionsDataESSourceXML.MisalignedFiles = cms.vstring("CondFormats/CTPPSReadoutObjects/xml/sample_alignment_corrections.xml") diff --git a/CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py b/CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py similarity index 92% rename from CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py rename to CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py index b7b818ac446fa..f86b3ad208a02 100644 --- a/CondFormats/CTPPSReadoutObjects/test/test_totemDAQMappingESSourceXML_cfg.py +++ b/CalibPPS/ESProducers/test/test_totemDAQMappingESSourceXML_cfg.py @@ -20,7 +20,7 @@ ) # load a mapping -process.load("CondFormats.CTPPSReadoutObjects.totemDAQMappingESSourceXML_cfi") +process.load("CalibPPS.ESProducers.totemDAQMappingESSourceXML_cfi") process.totemDAQMappingESSourceXML.subSystem = "TrackingStrip" process.totemDAQMappingESSourceXML.configuration = cms.VPSet( cms.PSet( diff --git a/Calibration/HcalCalibAlgos/macros/CalibCorr.C b/Calibration/HcalCalibAlgos/macros/CalibCorr.C index 3037f9f8fbf3b..25641e2ab879a 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibCorr.C +++ b/Calibration/HcalCalibAlgos/macros/CalibCorr.C @@ -67,25 +67,69 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug=false){ double puFactor(int type, int ieta, double pmom, double eHcal, double ediff) { double fac(1.0); - double frac = (type == 1) ? 0.02 : 0.03; - if (pmom > 0 && ediff > frac*pmom) { - double a1(0), a2(0); - if (type == 1) { - a1 = -0.35; a2 = -0.65; - if (std::abs(ieta) == 25) { - a2 = -0.30; - } else if (std::abs(ieta) > 25) { - a1 = -0.45; a2 = -0.10; + if (type <=2) { + double frac = (type == 1) ? 0.02 : 0.03; + if (pmom > 0 && ediff > frac*pmom) { + double a1(0), a2(0); + if (type == 1) { + a1 = -0.35; a2 = -0.65; + if (std::abs(ieta) == 25) { + a2 = -0.30; + } else if (std::abs(ieta) > 25) { + a1 = -0.45; a2 = -0.10; + } + } else { + a1 = -0.39; a2 = -0.59; + if (std::abs(ieta) >= 25) { + a1 = -0.283; a2 = -0.272; + } else if (std::abs(ieta) > 22) { + a1 = -0.238; a2 = -0.241; + } } + fac = (1.0+a1*(eHcal/pmom)*(ediff/pmom)*(1+a2*(ediff/pmom))); } else { - a1 = -0.39; a2 = -0.59; - if (std::abs(ieta) >= 25) { - a1 = -0.283; a2 = -0.272; - } else if (std::abs(ieta) > 22) { - a1 = -0.238; a2 = -0.241; + int jeta = std::abs(ieta); + double d2p = (ediff/pmom); + const double DELTA_CUT = 0.03; + const int PU_IETA_3 = 25; + if (type == 3) { // 16pu + const double CONST_COR_COEF[4] = { 0.971, 1.008, 0.985, 1.086 }; + const double LINEAR_COR_COEF[4] = { 0, -0.359, -0.251, -0.535 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.048, 0.143 }; + const int PU_IETA_1 = 9; + const int PU_IETA_2 = 16; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); + } else if (type == 4) { // 17pu + const double CONST_COR_COEF[4] = { 0.974, 1.023, 0.989, 1.077 }; + const double LINEAR_COR_COEF[4] = { 0, -0.524, -0.268, -0.584 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.053, 0.170 }; + const int PU_IETA_1 = 9; + const int PU_IETA_2 = 18; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); + } else { // 18pu + const double CONST_COR_COEF[4] = { 0.973, 0.998, 0.992, 0.965 }; + const double LINEAR_COR_COEF[4] = { 0, -0.318, -0.261, -0.406 }; + const double SQUARE_COR_COEF[4] = { 0, 0, 0.047, 0.089 }; + const int PU_IETA_1 = 7; + const int PU_IETA_2 = 16; + unsigned icor = (unsigned(jeta >= PU_IETA_1) + + unsigned(jeta >= PU_IETA_2) + + unsigned(jeta >= PU_IETA_3)); + if (d2p > DELTA_CUT) fac = (CONST_COR_COEF[icor] + + LINEAR_COR_COEF[icor]*d2p + + SQUARE_COR_COEF[icor]*d2p*d2p); } } - fac = (1.0+a1*(eHcal/pmom)*(ediff/pmom)*(1+a2*(ediff/pmom))); } return fac; } diff --git a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C index 683da9f8593a8..51d28a40f578d 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C +++ b/Calibration/HcalCalibAlgos/macros/CalibFitPlots.C @@ -154,6 +154,8 @@ #include #include +#include "CalibCorr.C" + struct cfactors { int ieta, depth; double corrf, dcorr; @@ -214,25 +216,6 @@ std::pair GetWidth(TH1D* hist, double xmin, double xmax) { return std::pair(rms,err); } -std::vector splitString (const std::string& fLine) { - std::vector result; - int start = 0; - bool empty = true; - for (unsigned i = 0; i <= fLine.size (); i++) { - if (fLine [i] == ' ' || i == fLine.size ()) { - if (!empty) { - std::string item (fLine, start, i-start); - result.push_back (item); - empty = true; - } - start = i+1; - } else { - if (empty) empty = false; - } - } - return result; -} - Double_t langaufun(Double_t *x, Double_t *par) { //Fit parameters: @@ -371,7 +354,7 @@ results fitTwoGauss (TH1D* hist, bool debug) { startvalues[4] = Fit->Value(1); lowValue[4] = 0.5*startvalues[4]; highValue[4] = 2.*startvalues[4]; startvalues[5] = 2.0*Fit->Value(2); lowValue[5] = 0.5*startvalues[5]; highValue[5] = 100.*startvalues[5]; //fitrange[0] = mean - 2.0*rms; fitrange[1] = mean + 2.0*rms; - fitrange[0] = Fit->Value(1) - 2.0*Fit->Value(2); fitrange[1] = Fit->Value(1) + 2.0*Fit->Value(2); + fitrange[0] = Fit->Value(1) - Fit->Value(2); fitrange[1] = Fit->Value(1) + Fit->Value(2); TFitResultPtr Fitfun = functionFit(hist, fitrange, startvalues, lowValue, highValue); double wt1 = (Fitfun->Value(0))*(Fitfun->Value(2)); double value1 = Fitfun->Value(1); @@ -660,7 +643,7 @@ void FitHistExtended(const char* infile, const char* outfile,std::string prefix, } if (hist0->GetEntries() > 10) { double rms; - results meaner0 = fitTwoGauss(hist0, debug); + results meaner0 = fitOneGauss(hist0,true,debug); std::pair meaner1 = GetMean(hist0,0.2,2.0,rms); std::pair meaner2 = GetWidth(hist0,0.2,2.0); if (debug) { @@ -704,7 +687,7 @@ void FitHistExtended(const char* infile, const char* outfile,std::string prefix, value = meaner.mean; error = meaner.errmean; width = meaner.width; werror= meaner.errwidth; } else { - results meaner = fitOneGauss(hist,false,debug); + results meaner = fitOneGauss(hist,true,debug); value = meaner.mean; error = meaner.errmean; width = meaner.width; werror= meaner.errwidth; } diff --git a/Calibration/HcalCalibAlgos/macros/CalibMonitor.C b/Calibration/HcalCalibAlgos/macros/CalibMonitor.C index ff073576a9812..8337df651e44d 100644 --- a/Calibration/HcalCalibAlgos/macros/CalibMonitor.C +++ b/Calibration/HcalCalibAlgos/macros/CalibMonitor.C @@ -796,12 +796,16 @@ void CalibMonitor::Loop() { unsigned int kp1 = ps_.size() - 1; unsigned int kv1 = 0; std::vector kounts(kp1,0); + std::vector kount50(20,0); for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; if (jentry%100000 == 0) std::cout << "Entry " << jentry << " Run " << t_Run << " Event " << t_Event << std::endl; + double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p; + bool p4060= ((pmom >= 40.0) && (pmom <= 60.0)); + if (p4060) ++kount50[0]; bool select = (std::find(entries_.begin(),entries_.end(),jentry) == entries_.end()); if (!select) { ++duplicate; @@ -810,11 +814,14 @@ void CalibMonitor::Loop() { << " " << t_p << std::endl; continue; } + if (p4060) ++kount50[1]; bool selRun = (includeRun_ ? ((t_Run >= runlo_) && (t_Run <= runhi_)) : ((t_Run < runlo_) || (t_Run > runhi_))); + if (select && p4060) ++kount50[2]; select = (selRun && (fabs(t_ieta) >= etalo_) && (fabs(t_ieta) <= etahi_) && (t_nVtx >= nvxlo_) && (t_nVtx <= nvxhi_)); + if (select && p4060) ++kount50[3]; if (!select) { if (debug) std::cout << "Run # " << t_Run << " out of range of " << runlo_ << ":" @@ -825,11 +832,12 @@ void CalibMonitor::Loop() { } if (cSelect_ != nullptr) { if (exclude_) { - if (cSelect_->isItRBX(t_DetIds)) continue; + if (cSelect_->isItRBX(t_DetIds)) continue; } else { if (!(cSelect_->isItRBX(t_ieta,t_iphi))) continue; } } + if (p4060) ++kount50[4]; select = (!cutL1T_ || (t_mindR1 >= 0.5)); if (!select) { if (debug) @@ -837,6 +845,7 @@ void CalibMonitor::Loop() { << " too close to L1 trigger " << t_mindR1 << std::endl; continue; } + if (p4060) ++kount50[5]; select = ((events_.size() == 0) || (std::find(events_.begin(),events_.end(), std::pair(t_Run,t_Event)) != events_.end())); @@ -846,10 +855,10 @@ void CalibMonitor::Loop() { << " not in the selection list" << std::endl; continue; } + if (p4060) ++kount50[6]; // if (Cut(ientry) < 0) continue; int kp(-1), jp(-1), jp1(-1); - double pmom = (useGen_ && (t_gentrackP > 0)) ? t_gentrackP : t_p; for (unsigned int k=1; k= ps_[k-1] && pmom < ps_[k]) { kp = k - 1; break; @@ -911,7 +920,9 @@ void CalibMonitor::Loop() { } } bool goodTk = goodTrack(eHcal, cut, debug); + if (goodTk && p4060) ++kount50[7]; bool selPhi = selectPhi(debug); + if (goodTk && selPhi && p4060) ++kount50[8]; if (pmom > 0) rat = (eHcal/(pmom-t_eMipDR)); if (debug) { std::cout << "Entry " << jentry << " p|eHcal|ratio " << pmom << "|" @@ -924,6 +935,7 @@ void CalibMonitor::Loop() { << ":" << kd << ":" << kd1 << ":" << jp << std::endl; } if (goodTk && kp >=0 && selPhi) { + if (p4060) ++kount50[9]; if (t_eHcal < 0.01) { std::map::const_iterator itr = runEn1.find(t_Run); if (itr == runEn1.end()) { @@ -939,6 +951,7 @@ void CalibMonitor::Loop() { } } if (t_eMipDR < 0.01 && t_eHcal < 0.01) { + if (p4060) ++kount50[10]; std::map::const_iterator itr = runEn2.find(t_Run); if (itr == runEn2.end()) { counter knt; @@ -953,6 +966,7 @@ void CalibMonitor::Loop() { } } if (rat > rcut) { + if (p4060) ++kount50[11]; if (plotType_ <= 1) { h_etaX[kp][kv]->Fill(eta,rat,t_EventWeight); h_etaX[kp][kv1]->Fill(eta,rat,t_EventWeight); @@ -983,6 +997,7 @@ void CalibMonitor::Loop() { } } if ((!dataMC_) || (t_mindR1 > 0.5) || (t_DataType == 1)) { + if (p4060) ++kount50[12]; ++kounts[kp]; if (plotType_ <= 1) { if (jp > 0) h_etaF[kp][jp]->Fill(rat,t_EventWeight); @@ -1017,6 +1032,7 @@ void CalibMonitor::Loop() { h_etaB[kp][jp1]->Fill(rat,t_EventWeight); h_etaB[kp][jp2]->Fill(rat,t_EventWeight); } + if (p4060) ++kount50[13]; } } } @@ -1066,6 +1082,9 @@ void CalibMonitor::Loop() { for (unsigned int k=1; k 21) std::cout << ps_[k-1] <<":"<< ps_[k] << " " << kounts[k-1] << std::endl; + std::cout << "Number in each step: "; + for (unsigned int k=0; k < 14; ++k) std::cout << " [" << k << "] " << kount50[k]; + std::cout < + + + + diff --git a/FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h b/CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h similarity index 84% rename from FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h rename to CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h index 9e5f0f4c4ea14..d58a5790a5eda 100644 --- a/FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h +++ b/CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h @@ -1,6 +1,6 @@ /*Emacs: -*- C++ -*- */ -#ifndef BASEPARTICLEPROPAGATOR_H -#define BASEPARTICLEPROPAGATOR_H +#ifndef CommonTools_BaseParticlePropagator_BaseParticlePropagator_h +#define CommonTools_BaseParticlePropagator_BaseParticlePropagator_h /** * This class is aimed at propagating charged and neutral @@ -77,9 +77,9 @@ * \version 15-Dec-2003 */ //FAMOS -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" -class BaseParticlePropagator : public RawParticle { +class BaseParticlePropagator { public: @@ -129,6 +129,7 @@ class BaseParticlePropagator : public RawParticle { void setPropagationConditions(double r, double z, bool firstLoop=true); private: + RawParticle particle_; /// Simulated particle that is to be resp has been propagated // RawParticle particle; /// Radius of the cylinder (centred at 0,0,0) to which propagation is done @@ -164,6 +165,11 @@ class BaseParticlePropagator : public RawParticle { public: + /// The particle being propagated + inline RawParticle const& particle() const { return particle_;} + inline RawParticle& particle() { return particle_;} + void setParticle(RawParticle const& iParticle) { particle_=iParticle;} + /// Set the proper decay time inline void setProperDecayTime(double t) { properDecayTime = t; } @@ -176,7 +182,7 @@ class BaseParticlePropagator : public RawParticle { /// Longitudinal impact parameter inline double zImpactParameter(double x0=0, double y0=0.) const { // Longitudinal impact parameter - return Z() - Pz() * std::sqrt( ((X()-x0)*(X()-x0) + (Y()-y0)*(Y()-y0) ) / Perp2()); + return particle_.Z() - particle_.Pz() * std::sqrt( ((particle_.X()-x0)*(particle_.X()-x0) + (particle_.Y()-y0)*(particle_.Y()-y0) ) / particle_.Perp2()); } /// The helix Radius @@ -189,40 +195,40 @@ class BaseParticlePropagator : public RawParticle { // Positive means anti-clockwise, negative means clockwise rotation. // // The radius is returned in cm to match the units in RawParticle. - return charge() == 0 ? 0.0 : - Pt() / ( c_light() * 1e-5 * bField * charge() ); + return particle_.charge() == 0 ? 0.0 : - particle_.Pt() / ( c_light() * 1e-5 * bField * particle_.charge() ); } inline double helixRadius(double pT) const { // a faster version of helixRadius, once Perp() has been computed - return charge() == 0 ? 0.0 : - pT / ( c_light() * 1e-5 * bField * charge() ); + return particle_.charge() == 0 ? 0.0 : - pT / ( c_light() * 1e-5 * bField * particle_.charge() ); } /// The azimuth of the momentum at the vertex inline double helixStartPhi() const { // The azimuth of the momentum at the vertex - return Px() == 0.0 && Py() == 0.0 ? 0.0 : std::atan2(Py(),Px()); + return particle_.Px() == 0.0 && particle_.Py() == 0.0 ? 0.0 : std::atan2(particle_.Py(),particle_.Px()); } /// The x coordinate of the helix axis inline double helixCentreX() const { // The x coordinate of the helix axis - return X() - helixRadius() * std::sin ( helixStartPhi() ); + return particle_.X() - helixRadius() * std::sin ( helixStartPhi() ); } inline double helixCentreX(double radius, double phi) const { // Fast version of helixCentreX() - return X() - radius * std::sin (phi); + return particle_.X() - radius * std::sin (phi); } /// The y coordinate of the helix axis inline double helixCentreY() const { // The y coordinate of the helix axis - return Y() + helixRadius() * std::cos ( helixStartPhi() ); + return particle_.Y() + helixRadius() * std::cos ( helixStartPhi() ); } inline double helixCentreY(double radius, double phi) const { // Fast version of helixCentreX() - return Y() + radius * std::cos (phi); + return particle_.Y() + radius * std::cos (phi); } /// The distance between the cylinder and the helix axes @@ -253,10 +259,10 @@ class BaseParticlePropagator : public RawParticle { /// Is the vertex inside the cylinder ? (stricly inside : true) inline bool inside() const { - return (R2() #include @@ -29,9 +27,23 @@ class ParticleTable; typedef math::XYZTLorentzVector XYZTLorentzVector; typedef math::XYZVector XYZVector; -class RawParticle : public XYZTLorentzVector { +class RawParticle; + +namespace rawparticle { + ///Create a particle with momentum 'p' at space-time point xStart + /// The particle will be a muon if iParticle==true, else it will + /// be an anti-muon. + RawParticle makeMuon(bool isParticle, const XYZTLorentzVector& p, + const XYZTLorentzVector& xStart); +} + +class RawParticle { public: + friend RawParticle rawparticle::makeMuon(bool, const XYZTLorentzVector&, const XYZTLorentzVector&); + friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, double mass, double charge); + friend RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart, double mass, double charge); + typedef ROOT::Math::AxisAngle Rotation; typedef ROOT::Math::Rotation3D Rotation3D; typedef ROOT::Math::RotationX RotationX; @@ -39,58 +51,35 @@ class RawParticle : public XYZTLorentzVector { typedef ROOT::Math::RotationZ RotationZ; typedef ROOT::Math::Boost Boost; - RawParticle(); - - virtual ~RawParticle(); + RawParticle() = default; /** Construct from a fourvector. * The fourvector is taken for the particle, the vertex is set to 0. */ RawParticle(const XYZTLorentzVector& p); - /** Construct from a fourvector and a PID. - * The fourvector and PID are taken for the particle, the vertex is set to 0. - */ - RawParticle(const int id, - const XYZTLorentzVector& p); - - /** Construct from a fourvector and a name. - * The fourvector and name are taken for the particle, the vertex is set to 0. - */ - RawParticle(const std::string name, - const XYZTLorentzVector& p); - /** Construct from 2 fourvectors. * The first fourvector is taken for the particle, the second for its vertex. */ RawParticle(const XYZTLorentzVector& p, - const XYZTLorentzVector& xStart); + const XYZTLorentzVector& xStart, + double charge = 0.); /** Construct from fourmomentum components. * Vertex is set to 0. */ - RawParticle(double px, double py, double pz, double e); + RawParticle(double px, double py, double pz, double e, double charge =0.); /** Copy constructor */ - RawParticle(const RawParticle &p); + RawParticle(const RawParticle &p) = default; + RawParticle(RawParticle &&p) = default; /** Copy assignment operator */ - RawParticle& operator = (const RawParticle & rhs ); + RawParticle& operator = (const RawParticle & rhs ) = default; + RawParticle& operator = (RawParticle&& rhs ) = default; public: - /** Set identifier for this particle. - * This should be a standard HEP-PID number. It will be used to deduce the - * name and the properties of the particle from a particle data table. - */ - void setID(const int id); - - /** Set identifier for this particle. - * This should be a standard HEP-PID name. It will be used to deduce the - * particle properties from a particle data table. - */ - void setID(const std::string name); - /** Set the status of this particle. * The coding follows PYTHIAs convention: * 1 = stable @@ -110,6 +99,15 @@ class RawParticle : public XYZTLorentzVector { void setVertex(const XYZTLorentzVector& vtx); void setVertex(double xv, double yv, double zv, double tv); + /// set the momentum + void setMomentum(const XYZTLorentzVector& vtx); + void setMomentum(double xv, double yv, double zv, double tv); + + void SetPx(double); + void SetPy(double); + void SetPz(double); + void SetE(double); + /*** methods to be overloaded to include vertex ***/ /** Boost the particle. @@ -170,17 +168,8 @@ class RawParticle : public XYZTLorentzVector { double charge() const; //!< get the MEASURED charge - double PDGcharge() const; //!< get the THEORETICAL charge - double mass() const; //!< get the MEASURED mass - double PDGmass() const; //!< get the THEORETICAL mass - - double PDGcTau() const; //!< get the THEORETICAL lifetime - - /// get the PDG name - std::string PDGname() const; - /** Get the pseudo rapidity of the particle. * \f$ \eta = -\log ( \tan ( \vartheta/2)) \f$ */ @@ -211,9 +200,36 @@ class RawParticle : public XYZTLorentzVector { double R2() const; //!< vertex radius**2 const XYZTLorentzVector& vertex() const; //!< the vertex fourvector - + + double px() const; //!< x of the momentum + double Px() const; //!< x of the momentum + + double py() const; //!< y of the momentum + double Py() const; //!< y of the momentum + + double pz() const; //!< z of the momentum + double Pz() const; //!< z of the momentum + + double e() const; //!< energy of the momentum + double E() const; //!< energy of the momentum + + double Pt() const; //!< transverse momentum + double pt() const; //!< transverse momentum + + double Perp2() const; //!< perpendicular momentum squared + + double mag() const; //!< the magnitude of the momentum + + double theta() const; //!< theta of momentum vector + double phi() const; //!< phi of momentum vector + + double M2() const; //!< mass squared + const XYZTLorentzVector& momentum() const; //!< the momentum fourvector + XYZTLorentzVector& momentum(); //!< the momentum fourvector + XYZVector Vect() const; //!< the momentum threevector + /** Print the name of the particle. * The name is deduced from the particle ID using a particle data table. * It is printed with a length of 10 characters. If the id number cannot @@ -242,21 +258,36 @@ class RawParticle : public XYZTLorentzVector { void reUse() { myUsed = 0;} private: - - void init(); - - protected: - - XYZTLorentzVector myVertex; //!< the four vector of the vertex - int myId; //!< the particle id number HEP-PID - int myStatus; //!< the status code according to PYTHIA - int myUsed; //!< status of the locking - double myCharge; //!< the MEASURED charge - double myMass; //!< the RECONSTRUCTED mass - const ParticleData* myInfo; //!< The pointer to the PDG info + + /** Construct from a fourvector and a PID. + * The fourvector and PID are taken for the particle, the vertex is set to 0. + */ + RawParticle(const int id, + const XYZTLorentzVector& p, + double mass, + double charge); + + + /** Construct from 2 fourvectosr and a PID. + * The fourvector and PID are taken for the particle, the vertex is set to 0. + */ + RawParticle(const int id, + const XYZTLorentzVector& p, + const XYZTLorentzVector& xStart, + double mass, + double charge); + private: - const ParticleTable* tab; + + XYZTLorentzVector myMomentum; //!< the four vector of the momentum + XYZTLorentzVector myVertex; //!< the four vector of the vertex + double myCharge= 0.; //!< the MEASURED charge + double myMass = 0.; //!< the RECONSTRUCTED mass + int myId = 0; //!< the particle id number HEP-PID + int myStatus=99; //!< the status code according to PYTHIA + int myUsed = 0; //!< status of the locking + }; @@ -265,7 +296,7 @@ std::ostream& operator <<(std::ostream& o , const RawParticle& p); inline int RawParticle::pid() const { return myId; } inline int RawParticle::status() const { return myStatus; } inline double RawParticle::eta() const { return -std::log(std::tan(this->theta()/2.)); } -inline double RawParticle::cos2Theta() const { return Pz()*Pz()/Vect().Mag2(); } +inline double RawParticle::cos2Theta() const { return Pz()*Pz()/myMomentum.Vect().Mag2(); } inline double RawParticle::cos2ThetaV() const { return Z()*Z()/myVertex.Vect().Mag2(); } inline double RawParticle::x() const { return myVertex.Px(); } inline double RawParticle::y() const { return myVertex.Py(); } @@ -281,43 +312,73 @@ inline double RawParticle::r() const { return std::sqrt(r2()); } inline double RawParticle::r2() const { return myVertex.Perp2(); } inline double RawParticle::charge() const { return myCharge; } inline double RawParticle::mass() const { return myMass; } +inline double RawParticle::px() const { return myMomentum.px() ; } +inline double RawParticle::Px() const { return myMomentum.Px() ; } + +inline double RawParticle::py() const { return myMomentum.py() ; } +inline double RawParticle::Py() const { return myMomentum.Py() ; } + +inline double RawParticle::pz() const { return myMomentum.pz() ; } +inline double RawParticle::Pz() const { return myMomentum.Pz() ; } + +inline double RawParticle::e() const { return myMomentum.e() ; } +inline double RawParticle::E() const { return myMomentum.E() ; } + +inline double RawParticle::Pt() const { return myMomentum.Pt() ; } +inline double RawParticle::pt() const { return myMomentum.pt() ; } + +inline double RawParticle::Perp2() const { return myMomentum.Perp2(); } + +inline double RawParticle::mag() const { return myMomentum.mag(); } + +inline double RawParticle::theta() const { return myMomentum.theta(); } +inline double RawParticle::phi() const { return myMomentum.phi(); } + +inline double RawParticle::M2() const { return myMomentum.M2(); } inline const XYZTLorentzVector& RawParticle::vertex() const { return myVertex ; } -inline const XYZTLorentzVector& RawParticle::momentum() const { return *this; } +inline const XYZTLorentzVector& RawParticle::momentum() const { return myMomentum; } +inline XYZTLorentzVector& RawParticle::momentum() { return myMomentum; } +inline XYZVector RawParticle::Vect() const { return myMomentum.Vect(); } inline void RawParticle::setVertex(const XYZTLorentzVector& vtx) { myVertex = vtx; } inline void RawParticle::setVertex(double a, double b, double c, double d) { myVertex.SetXYZT(a,b,c,d); } +inline void RawParticle::setMomentum(const XYZTLorentzVector& p4) { myMomentum = p4; } +inline void RawParticle::setMomentum(double a, double b, double c, double d) { myMomentum.SetXYZT(a,b,c,d); } + +inline void RawParticle::SetPx(double px) {myMomentum.SetPx(px);} +inline void RawParticle::SetPy(double py) {myMomentum.SetPy(py);} +inline void RawParticle::SetPz(double pz) {myMomentum.SetPz(pz);} +inline void RawParticle::SetE(double e) {myMomentum.SetE(e);} + + inline void RawParticle::rotate(const RawParticle::Rotation3D& r) { - XYZVector v ( r(Vect()) ); SetXYZT(v.X(),v.Y(),v.Z(),E()); + XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E()); } inline void RawParticle::rotate(const RawParticle::Rotation& r) { - XYZVector v ( r(Vect()) ); SetXYZT(v.X(),v.Y(),v.Z(),E()); + XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E()); } inline void RawParticle::rotate(const RawParticle::RotationX& r) { - XYZVector v ( r(Vect()) ); SetXYZT(v.X(),v.Y(),v.Z(),E()); + XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E()); } inline void RawParticle::rotate(const RawParticle::RotationY& r) { - XYZVector v ( r(Vect()) ); SetXYZT(v.X(),v.Y(),v.Z(),E()); + XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E()); } inline void RawParticle::rotate(const RawParticle::RotationZ& r) { - XYZVector v ( r(Vect()) ); SetXYZT(v.X(),v.Y(),v.Z(),E()); + XYZVector v ( r(myMomentum.Vect()) ); setMomentum(v.X(),v.Y(),v.Z(),E()); } inline void RawParticle::boost(const RawParticle::Boost& b) { - XYZTLorentzVector p ( b(momentum()) ); SetXYZT(p.Px(),p.Py(),p.Pz(),p.E()); + XYZTLorentzVector p ( b(momentum()) ); setMomentum(p.Px(),p.Py(),p.Pz(),p.E()); } inline void RawParticle::translate(const XYZVector& tr) { myVertex.SetXYZT(X()+tr.X(),Y()+tr.Y(),Z()+tr.Z(),T()); } - - - - #endif diff --git a/CommonTools/BaseParticlePropagator/interface/makeMuon.h b/CommonTools/BaseParticlePropagator/interface/makeMuon.h new file mode 100644 index 0000000000000..edda93ce8c3a0 --- /dev/null +++ b/CommonTools/BaseParticlePropagator/interface/makeMuon.h @@ -0,0 +1,37 @@ +#ifndef CommonTools_BaseParticlePropagator_makeMuon_h +#define CommonTools_BaseParticlePropagator_makeMuon_h +// -*- C++ -*- +// +// Package: CommonTools/BaseParticlePropagator +// Class : makeMuon +// +/**\class makeMuon makeMuon.h "CommonTools/BaseParticlePropagator/interface/makeMuon.h" + + Description: Creates a RawParticle of type muon + + Usage: + + +*/ +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 17:36:32 GMT +// + +// system include files +#include "DataFormats/Math/interface/LorentzVector.h" + +// user include files + +// forward declarations +class RawParticle; + +namespace rawparticle { + ///Create a particle with momentum 'p' at space-time point xStart + /// The particle will be a muon if iParticle==true, else it will + /// be an anti-muon. + RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector& p, + const math::XYZTLorentzVector& xStart); +} + +#endif diff --git a/FastSimulation/BaseParticlePropagator/src/BaseParticlePropagator.cc b/CommonTools/BaseParticlePropagator/src/BaseParticlePropagator.cc similarity index 78% rename from FastSimulation/BaseParticlePropagator/src/BaseParticlePropagator.cc rename to CommonTools/BaseParticlePropagator/src/BaseParticlePropagator.cc index 66e45664063a6..dec06f5635175 100644 --- a/FastSimulation/BaseParticlePropagator/src/BaseParticlePropagator.cc +++ b/CommonTools/BaseParticlePropagator/src/BaseParticlePropagator.cc @@ -1,20 +1,21 @@ //FAMOS headers -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include BaseParticlePropagator::BaseParticlePropagator() : - RawParticle(), rCyl(0.), rCyl2(0.), zCyl(0.), bField(0), properDecayTime(1E99) + rCyl(0.), rCyl2(0.), zCyl(0.), bField(0), properDecayTime(1E99) {;} BaseParticlePropagator::BaseParticlePropagator( const RawParticle& myPart,double R, double Z, double B, double t ) : - RawParticle(myPart), rCyl(R), rCyl2(R*R), zCyl(Z), bField(B), properDecayTime(t) + particle_(myPart), rCyl(R), rCyl2(R*R), zCyl(Z), bField(B), properDecayTime(t) { init(); } BaseParticlePropagator::BaseParticlePropagator( const RawParticle& myPart,double R, double Z, double B) : - RawParticle(myPart), rCyl(R), rCyl2(R*R), zCyl(Z), bField(B), properDecayTime(1E99) + particle_(myPart), rCyl(R), rCyl2(R*R), zCyl(Z), bField(B), properDecayTime(1E99) { init(); } @@ -46,7 +47,7 @@ BaseParticlePropagator::propagate() { // // Check that the particle is not already on the cylinder surface // - double rPos2 = R2(); + double rPos2 = particle_.R2(); if ( onBarrel(rPos2) ) { success = 1; @@ -60,16 +61,16 @@ BaseParticlePropagator::propagate() { // // Treat neutral particles (or no magnetic field) first // - if ( fabs(charge()) < 1E-12 || bField < 1E-12 ) { + if ( fabs(particle_.charge()) < 1E-12 || bField < 1E-12 ) { // // First check that the particle crosses the cylinder // - double pT2 = Perp2(); + double pT2 = particle_.Perp2(); // double pT2 = pT*pT; // double b2 = rCyl * pT; double b2 = rCyl2 * pT2; - double ac = fabs ( X()*Py() - Y()*Px() ); + double ac = fabs ( particle_.X()*particle_.Py() - particle_.Y()*particle_.Px() ); double ac2 = ac*ac; // // The particle never crosses (or never crossed) the cylinder @@ -79,8 +80,8 @@ BaseParticlePropagator::propagate() { // double delta = std::sqrt(b2*b2 - ac*ac); double delta = std::sqrt(b2 - ac2); - double tplus = -( X()*Px()+Y()*Py() ) + delta; - double tminus = -( X()*Px()+Y()*Py() ) - delta; + double tplus = -( particle_.X()*particle_.Px()+particle_.Y()*particle_.Py() ) + delta; + double tminus = -( particle_.X()*particle_.Px()+particle_.Y()*particle_.Py() ) - delta; // // Find the first (time-wise) intersection point with the cylinder // @@ -90,13 +91,13 @@ BaseParticlePropagator::propagate() { // // Check that the particle does (did) not exit from the endcaps first. // - double zProp = Z() + Pz() * solution; + double zProp = particle_.Z() + particle_.Pz() * solution; if ( fabs(zProp) > zCyl ) { - tplus = ( zCyl - Z() ) / Pz(); - tminus = (-zCyl - Z() ) / Pz(); + tplus = ( zCyl - particle_.Z() ) / particle_.Pz(); + tminus = (-zCyl - particle_.Z() ) / particle_.Pz(); solution = tminus < 0 ? tplus : tminus; if ( solution < 0. ) return false; - zProp = Z() + Pz() * solution; + zProp = particle_.Z() + particle_.Pz() * solution; success = 2; } else { @@ -106,7 +107,7 @@ BaseParticlePropagator::propagate() { // // Check the decay time // - double delTime = propDir * mass() * solution; + double delTime = propDir * particle_.mass() * solution; double factor = 1.; properTime += delTime; if ( properTime > properDecayTime ) { @@ -118,10 +119,10 @@ BaseParticlePropagator::propagate() { // // Compute the coordinates of the RawParticle after propagation // - double xProp = X() + Px() * solution * factor; - double yProp = Y() + Py() * solution * factor; - zProp = Z() + Pz() * solution * factor; - double tProp = T() + E() * solution * factor; + double xProp = particle_.X() + particle_.Px() * solution * factor; + double yProp = particle_.Y() + particle_.Py() * solution * factor; + zProp = particle_.Z() + particle_.Pz() * solution * factor; + double tProp = particle_.T() + particle_.E() * solution * factor; // // Last check : Although propagated to the endcaps, R could still be @@ -135,7 +136,7 @@ BaseParticlePropagator::propagate() { // // ... and update the particle with its propagated coordinates // - setVertex( XYZTLorentzVector(xProp,yProp,zProp,tProp) ); + particle_.setVertex( XYZTLorentzVector(xProp,yProp,zProp,tProp) ); return true; } @@ -146,7 +147,7 @@ BaseParticlePropagator::propagate() { // // First check that the particle can cross the cylinder // - double pT = Pt(); + double pT = particle_.Pt(); double radius = helixRadius(pT); double phi0 = helixStartPhi(); double xC = helixCentreX(radius,phi0); @@ -160,12 +161,12 @@ BaseParticlePropagator::propagate() { // The particle is already away from the endcaps, and will never come back // Could be back-propagated, so warn the user that it is so. // - if ( Z() * Pz() > zCyl * fabs(Pz()) ) { + if ( particle_.Z() * particle_.Pz() > zCyl * fabs(particle_.Pz()) ) { success = -2; return true; } - double pZ = Pz(); + double pZ = particle_.Pz(); double phiProp, zProp; // // Does the helix cross the cylinder barrel ? If not, do the first half-loop @@ -184,9 +185,9 @@ BaseParticlePropagator::propagate() { double cphi0 = std::cos(phi0); double sphi0 = std::sin(phi0); - double r0 = (X()*cphi0 + Y()*sphi0)/radius; - double q0 = (X()*sphi0 - Y()*cphi0)/radius; - double rcyl2 = (rCyl2 - X()*X() - Y()*Y())/(radius*radius); + double r0 = (particle_.X()*cphi0 + particle_.Y()*sphi0)/radius; + double q0 = (particle_.X()*sphi0 - particle_.Y()*cphi0)/radius; + double rcyl2 = (rCyl2 - particle_.X()*particle_.X() - particle_.Y()*particle_.Y())/(radius*radius); double delta = r0*r0 + rcyl2*(1.-q0); // This is a solution of a second order equation, assuming phi = phi0 + epsilon @@ -234,11 +235,11 @@ BaseParticlePropagator::propagate() { // // Check that the particle does not exit from the endcaps first. // - zProp = Z() + ( phiProp - phi0 ) * pZ * radius / pT ; + zProp = particle_.Z() + ( phiProp - phi0 ) * pZ * radius / pT ; if ( fabs(zProp) > zCyl ) { zProp = zCyl * fabs(pZ)/pZ; - phiProp = phi0 + (zProp - Z()) / radius * pT / pZ; + phiProp = phi0 + (zProp - particle_.Z()) / radius * pT / pZ; success = 2; } else { @@ -256,7 +257,7 @@ BaseParticlePropagator::propagate() { } else { zProp = zCyl * fabs(pZ)/pZ; - phiProp = phi0 + (zProp - Z()) / radius * pT / pZ; + phiProp = phi0 + (zProp - particle_.Z()) / radius * pT / pZ; success = 2; } @@ -275,7 +276,7 @@ BaseParticlePropagator::propagate() { // // Check the decay time // - double delTime = propDir * (phiProp-phi0)*radius*mass() / pT; + double delTime = propDir * (phiProp-phi0)*radius*particle_.mass() / pT; double factor = 1.; properTime += delTime; if ( properTime > properDecayTime ) { @@ -284,7 +285,7 @@ BaseParticlePropagator::propagate() { decayed = true; } - zProp = Z() + (zProp-Z())*factor; + zProp = particle_.Z() + (zProp-particle_.Z())*factor; phiProp = phi0 + (phiProp-phi0)*factor; @@ -292,7 +293,7 @@ BaseParticlePropagator::propagate() { double cProp = std::cos(phiProp); double xProp = xC + radius * sProp; double yProp = yC - radius * cProp; - double tProp = T() + (phiProp-phi0)*radius*E()/pT; + double tProp = particle_.T() + (phiProp-phi0)*radius*particle_.E()/pT; double pxProp = pT * cProp; double pyProp = pT * sProp; @@ -307,10 +308,10 @@ BaseParticlePropagator::propagate() { // // ... and update the particle vertex and momentum // - setVertex( XYZTLorentzVector(xProp,yProp,zProp,tProp) ); - SetXYZT(pxProp,pyProp,pZ,E()); - // SetPx(pxProp); - // SetPy(pyProp); + particle_.setVertex( XYZTLorentzVector(xProp,yProp,zProp,tProp) ); + particle_.setMomentum(pxProp,pyProp,pZ,particle_.E()); + // particle_.SetPx(pxProp); + // particle_.SetPy(pyProp); return true; } @@ -320,12 +321,12 @@ bool BaseParticlePropagator::backPropagate() { // Backpropagate - SetXYZT(-Px(),-Py(),-Pz(),E()); - setCharge(-charge()); + particle_.setMomentum(-particle_.Px(),-particle_.Py(),-particle_.Pz(),particle_.E()); + particle_.setCharge(-particle_.charge()); propDir = -1; bool done = propagate(); - SetXYZT(-Px(),-Py(),-Pz(),E()); - setCharge(-charge()); + particle_.setMomentum(-particle_.Px(),-particle_.Py(),-particle_.Pz(),particle_.E()); + particle_.setCharge(-particle_.charge()); propDir = +1; return done; @@ -358,7 +359,7 @@ bool BaseParticlePropagator::propagateToClosestApproach(double x0, double y0, bool first) { // Pre-computed quantities - double pT = Pt(); + double pT = particle_.Pt(); double radius = helixRadius(pT); double phi0 = helixStartPhi(); @@ -373,12 +374,12 @@ BaseParticlePropagator::propagateToClosestApproach(double x0, double y0, bool fi // Propagation to point of clostest approach to z axis // double rz,r0,z; - if ( charge() != 0.0 && bField != 0.0 ) { + if ( particle_.charge() != 0.0 && bField != 0.0 ) { rz = fabs ( fabs(radius) - distz ) + std::sqrt(x0*x0+y0*y0) + 0.0000001; r0 = fabs ( fabs(radius) - dist0 ) + 0.0000001; } else { - rz = fabs( Px() * (Y()-y0) - Py() * (X()-x0) ) / Pt(); - r0 = fabs( Px() * Y() - Py() * X() ) / Pt(); + rz = fabs( particle_.Px() * (particle_.Y()-y0) - particle_.Py() * (particle_.X()-x0) ) / particle_.Pt(); + r0 = fabs( particle_.Px() * particle_.Y() - particle_.Py() * particle_.X() ) / particle_.Pt(); } z = 999999.; @@ -393,14 +394,14 @@ BaseParticlePropagator::propagateToClosestApproach(double x0, double y0, bool fi // The z axis is (0,0) - no need to go further if ( fabs(rz-r0) < 1E-10 ) return done; - double dist1 = (X()-x0)*(X()-x0) + (Y()-y0)*(Y()-y0); + double dist1 = (particle_.X()-x0)*(particle_.X()-x0) + (particle_.Y()-y0)*(particle_.Y()-y0); // We are already at closest approach - no need to go further if ( dist1 < 1E-10 ) return done; // Keep for later if it happens to be the right solution - XYZTLorentzVector vertex1 = vertex(); - XYZTLorentzVector momentum1 = momentum(); + XYZTLorentzVector vertex1 = particle_.vertex(); + XYZTLorentzVector momentum1 = particle_.momentum(); // Propagate to the distance of closest approach to (0,0) setPropagationConditions(r0 , z, first); @@ -412,12 +413,12 @@ BaseParticlePropagator::propagateToClosestApproach(double x0, double y0, bool fi setPropagationConditions(rz , z, first); done = backPropagate(); if ( !done ) return done; - double dist2 = (X()-x0)*(X()-x0) + (Y()-y0)*(Y()-y0); + double dist2 = (particle_.X()-x0)*(particle_.X()-x0) + (particle_.Y()-y0)*(particle_.Y()-y0); // Keep the good solution. if ( dist2 > dist1 ) { - setVertex(vertex1); - SetXYZT(momentum1.X(),momentum1.Y(),momentum1.Z(),momentum1.E()); + particle_.setVertex(vertex1); + particle_.setMomentum(momentum1.X(),momentum1.Y(),momentum1.Z(),momentum1.E()); dist2 = dist1; } @@ -456,7 +457,7 @@ BaseParticlePropagator::propagateToPreshowerLayer1(bool first) { bool done = propagate(); // Check that were are on the Layer 1 - if ( done && (R2() > 125.0*125.0 || R2() < 45.0*45.0) ) + if ( done && (particle_.R2() > 125.0*125.0 || particle_.R2() < 45.0*45.0) ) success = 0; return done; @@ -476,7 +477,7 @@ BaseParticlePropagator::propagateToPreshowerLayer2(bool first) { bool done = propagate(); // Check that we are on Layer 2 - if ( done && (R2() > 125.0*125.0 || R2() < 45.0*45.0 ) ) + if ( done && (particle_.R2() > 125.0*125.0 || particle_.R2() < 45.0*45.0 ) ) success = 0; return done; @@ -497,14 +498,14 @@ BaseParticlePropagator::propagateToEcalEntrance(bool first) { // Go to endcap cylinder in the "barrel cut corner" // eta = 1.479 -> cos^2(theta) = 0.81230 // if ( done && eta > 1.479 && success == 1 ) { - if ( done && cos2ThetaV() > 0.81230 && success == 1 ) { + if ( done && particle_.cos2ThetaV() > 0.81230 && success == 1 ) { setPropagationConditions(152.6 , 320.9, first); done = propagate(); } // We are not in the ECAL acceptance // eta = 3.0 -> cos^2(theta) = 0.99013 - if ( cos2ThetaV() > 0.99014 ) success = 0; + if ( particle_.cos2ThetaV() > 0.99014 ) success = 0; return done; } @@ -534,7 +535,7 @@ BaseParticlePropagator::propagateToHcalEntrance(bool first) { // out of the HB/HE acceptance // eta = 3.0 -> cos^2(theta) = 0.99014 - if ( done && cos2ThetaV() > 0.99014 ) success = 0; + if ( done && particle_.cos2ThetaV() > 0.99014 ) success = 0; return done; } @@ -556,7 +557,7 @@ BaseParticlePropagator::propagateToVFcalEntrance(bool first) { // We are not in the VFCAL acceptance // eta = 3.0 -> cos^2(theta) = 0.99014 // eta = 5.2 -> cos^2(theta) = 0.9998755 - double c2teta = cos2ThetaV(); + double c2teta = particle_.cos2ThetaV(); if ( done && ( c2teta < 0.99014 || c2teta > 0.9998755 ) ) success = 0; return done; @@ -572,7 +573,7 @@ BaseParticlePropagator::propagateToHcalExit(bool first) { // Approximate it to a single cylinder as it is not that crucial. setPropagationConditions(263.9 , 554.1, first); - // this->rawPart().setCharge(0.0); ?? Shower Propagation ?? + // this->rawPart().particle_.setCharge(0.0); ?? Shower Propagation ?? propDir = 0; bool done = propagate(); propDir = 1; @@ -596,7 +597,7 @@ BaseParticlePropagator::propagateToHOLayer(bool first) { bool done = propagate(); propDir = 1; - if ( done && std::abs(Z()) > 700.25) success = 0; + if ( done && std::abs(particle_.Z()) > 700.25) success = 0; return done; } @@ -608,19 +609,19 @@ BaseParticlePropagator::propagateToNominalVertex(const XYZTLorentzVector& v) // Not implemented for neutrals (used for electrons only) - if ( charge() == 0. || bField == 0.) return false; + if ( particle_.charge() == 0. || bField == 0.) return false; // Define the proper pT direction to meet the point (vx,vy) in (x,y) - double dx = X()-v.X(); - double dy = Y()-v.Y(); + double dx = particle_.X()-v.X(); + double dy = particle_.Y()-v.Y(); double phi = std::atan2(dy,dx) + std::asin ( std::sqrt(dx*dx+dy*dy)/(2.*helixRadius()) ); // The absolute pT (kept to the original value) - double pT = pt(); + double pT = particle_.pt(); // Set the new pT - SetPx(pT*std::cos(phi)); - SetPy(pT*std::sin(phi)); + particle_.SetPx(pT*std::cos(phi)); + particle_.SetPy(pT*std::sin(phi)); return propagateToClosestApproach(v.X(),v.Y()); @@ -631,8 +632,8 @@ BaseParticlePropagator::propagateToBeamCylinder(const XYZTLorentzVector& v, doub { // For neutral (or BField = 0, simply check that the track passes through the cylinder - if ( charge() == 0. || bField == 0.) - return fabs( Px() * Y() - Py() * X() ) / Pt() < radius; + if ( particle_.charge() == 0. || bField == 0.) + return fabs( particle_.Px() * particle_.Y() - particle_.Py() * particle_.X() ) / particle_.Pt() < radius; // Now go to the charged particles @@ -642,11 +643,11 @@ BaseParticlePropagator::propagateToBeamCylinder(const XYZTLorentzVector& v, doub double r2 = r*r; double r4 = r2*r2; // The two hits - double dx = X()-v.X(); - double dy = Y()-v.Y(); - double dz = Z()-v.Z(); - double Sxy = X()*v.X() + Y()*v.Y(); - double Dxy = Y()*v.X() - X()*v.Y(); + double dx = particle_.X()-v.X(); + double dy = particle_.Y()-v.Y(); + double dz = particle_.Z()-v.Z(); + double Sxy = particle_.X()*v.X() + particle_.Y()*v.Y(); + double Dxy = particle_.Y()*v.X() - particle_.X()*v.Y(); double Dxy2 = Dxy*Dxy; double Sxy2 = Sxy*Sxy; double SDxy = dx*dx + dy*dy; @@ -659,13 +660,13 @@ BaseParticlePropagator::propagateToBeamCylinder(const XYZTLorentzVector& v, doub // Here are the four possible solutions for // 1) The trajectory radius - std::vector helixRs(4,static_cast(0.)); + std::array helixRs = {{0.}}; helixRs[0] = (b - std::sqrt(b*b - a*c))/(2.*a); helixRs[1] = (b + std::sqrt(b*b - a*c))/(2.*a); helixRs[2] = -helixRs[0]; helixRs[3] = -helixRs[1]; // 2) The azimuthal direction at the second point - std::vector helixPhis(4,static_cast(0.)); + std::array helixPhis = {{0.}}; helixPhis[0] = std::asin ( SSDxy/(2.*helixRs[0]) ); helixPhis[1] = std::asin ( SSDxy/(2.*helixRs[1]) ); helixPhis[2] = -helixPhis[0]; @@ -726,24 +727,24 @@ BaseParticlePropagator::propagateToBeamCylinder(const XYZTLorentzVector& v, doub } else if ( solution1*solution2 < 0. ) { pT = 1000.; double norm = pT/SSDxy; - setCharge(+1.); - SetXYZT(dx*norm,dy*norm,dz*norm,0.); - SetE(std::sqrt(Vect().Mag2())); + particle_.setCharge(+1.); + particle_.setMomentum(dx*norm,dy*norm,dz*norm,0.); + particle_.SetE(std::sqrt(particle_.momentum().Vect().Mag2())); // Otherwise take the solution that gives the largest transverse momentum } else { if (solution1<0.) { helixR = solution1; helixPhi = phi1; - setCharge(+1.); + particle_.setCharge(+1.); } else { helixR = solution2; helixPhi = phi2; - setCharge(-1.); + particle_.setCharge(-1.); } pT = fabs(helixR) * 1e-5 * c_light() *bField; double norm = pT/SSDxy; - SetXYZT(pT*std::cos(helixPhi),pT*std::sin(helixPhi),dz*norm,0.); - SetE(std::sqrt(Vect().Mag2())); + particle_.setMomentum(pT*std::cos(helixPhi),pT*std::sin(helixPhi),dz*norm,0.); + particle_.SetE(std::sqrt(particle_.momentum().Vect().Mag2())); } // Propagate to closest approach to get the Z value (a bit of an overkill) @@ -755,9 +756,9 @@ double BaseParticlePropagator::xyImpactParameter(double x0, double y0) const { double ip=0.; - double pT = Pt(); + double pT = particle_.Pt(); - if ( charge() != 0.0 && bField != 0.0 ) { + if ( particle_.charge() != 0.0 && bField != 0.0 ) { double radius = helixRadius(pT); double phi0 = helixStartPhi(); @@ -767,7 +768,7 @@ BaseParticlePropagator::xyImpactParameter(double x0, double y0) const { double distz = helixCentreDistToAxis(xC-x0,yC-y0); ip = distz - fabs(radius); } else { - ip = fabs( Px() * (Y()-y0) - Py() * (X()-x0) ) / pT; + ip = fabs( particle_.Px() * (particle_.Y()-y0) - particle_.Py() * (particle_.X()-x0) ) / pT; } return ip; diff --git a/CommonTools/BaseParticlePropagator/src/RawParticle.cc b/CommonTools/BaseParticlePropagator/src/RawParticle.cc new file mode 100644 index 0000000000000..6000723626da1 --- /dev/null +++ b/CommonTools/BaseParticlePropagator/src/RawParticle.cc @@ -0,0 +1,142 @@ +// ----------------------------------------------------------------------------- +// Prototype for a particle class +// ----------------------------------------------------------------------------- +// $Date: 2007/09/07 16:46:22 $ +// $Revision: 1.13 $ +// ----------------------------------------------------------------------------- +// Author: Stephan Wynhoff - RWTH-Aachen (Email: Stephan.Wynhoff@cern.ch) +// ----------------------------------------------------------------------------- +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" + +#include + +RawParticle::RawParticle(const XYZTLorentzVector& p) + : myMomentum(p) { +} + +RawParticle::RawParticle(const int id, + const XYZTLorentzVector& p, + double mass, + double charge) : + myMomentum(p), + myCharge{charge}, + myMass{mass}, + myId{id} +{ +} + +RawParticle::RawParticle(const int id, + const XYZTLorentzVector& p, + const XYZTLorentzVector& xStart, + double mass, + double charge) : + myMomentum(p), + myVertex{xStart}, + myCharge{charge}, + myMass{mass}, + myId{id} +{ +} + +RawParticle::RawParticle(const XYZTLorentzVector& p, + const XYZTLorentzVector& xStart, + double charge) : + myMomentum(p), + myVertex{xStart}, + myCharge{charge} +{ +} + +RawParticle::RawParticle(double px, double py, double pz, double e, double charge) : + myMomentum(px,py,pz,e), + myCharge{charge} +{ +} + +void +RawParticle::setStatus(int istat) { + myStatus = istat; +} + +void +RawParticle::setMass(float m) { + myMass = m; +} + +void +RawParticle::setCharge(float q) { + myCharge = q; +} + +void +RawParticle::chargeConjugate() { + myId = -myId; + myCharge = -1*myCharge; +} + +void +RawParticle::setT(const double t) { + myVertex.SetE(t); +} + +void +RawParticle::rotate(double angle, const XYZVector& raxis) { + Rotation r(raxis,angle); + XYZVector v(r * myMomentum.Vect()); + setMomentum(v.X(),v.Y(),v.Z(),E()); +} + +void +RawParticle::rotateX(double rphi) { + RotationX r(rphi); + XYZVector v(r * myMomentum.Vect()); + setMomentum(v.X(),v.Y(),v.Z(),E()); +} + +void +RawParticle::rotateY(double rphi) { + RotationY r(rphi); + XYZVector v(r * myMomentum.Vect()); + setMomentum(v.X(),v.Y(),v.Z(),E()); +} + +void +RawParticle::rotateZ(double rphi) { + RotationZ r(rphi); + XYZVector v(r * myMomentum.Vect()); + setMomentum(v.X(),v.Y(),v.Z(),E()); +} + +void +RawParticle::boost(double betax, double betay, double betaz) { + Boost b(betax,betay,betaz); + XYZTLorentzVector p ( b * momentum() ); + setMomentum(p.X(),p.Y(),p.Z(),p.T()); +} + + +std::ostream& operator <<(std::ostream& o , const RawParticle& p) { + + o.setf(std::ios::fixed, std::ios::floatfield); + o.setf(std::ios::right, std::ios::adjustfield); + + + o << std::setw(4) << std::setprecision(2) << p.pid() << " ("; + o << std::setw(2) << std::setprecision(2) << p.status() << "): "; + o << std::setw(10) << std::setprecision(4) << p.momentum() << " "; + o << std::setw(10) << std::setprecision(4) << p.vertex(); + return o; + +} + +double +RawParticle::et() const { + double mypp, tmpEt=-1.; + + mypp = std::sqrt(momentum().mag2()); + if ( mypp != 0 ) { + tmpEt = E() * pt() / mypp; + } + return tmpEt; +} + diff --git a/CommonTools/BaseParticlePropagator/src/makeMuon.cc b/CommonTools/BaseParticlePropagator/src/makeMuon.cc new file mode 100644 index 0000000000000..7582cba3b0b1c --- /dev/null +++ b/CommonTools/BaseParticlePropagator/src/makeMuon.cc @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// Package: CommonTools/BaseParticlePropagator +// Class : makeMuon +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 17:36:54 GMT +// + +// system include files + +// user include files +#include "CommonTools/BaseParticlePropagator/interface/makeMuon.h" + +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" +namespace rawparticle { + RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector& p, + const math::XYZTLorentzVector& xStart) { + constexpr double kMass = 0.10566; //taken from SimGeneral/HepPDTESSource/data/particle.tbl + if(isParticle) { + return RawParticle(13, p,xStart,kMass,-1.); + } + return RawParticle(-13,p,xStart, kMass, +1.); + } +} diff --git a/CommonTools/BaseParticlePropagator/test/BuildFile.xml b/CommonTools/BaseParticlePropagator/test/BuildFile.xml new file mode 100644 index 0000000000000..8569fd5a20fba --- /dev/null +++ b/CommonTools/BaseParticlePropagator/test/BuildFile.xml @@ -0,0 +1,4 @@ + + + + diff --git a/CommonTools/BaseParticlePropagator/test/makeMuon_catch2.cc b/CommonTools/BaseParticlePropagator/test/makeMuon_catch2.cc new file mode 100644 index 0000000000000..2d6b1d3132485 --- /dev/null +++ b/CommonTools/BaseParticlePropagator/test/makeMuon_catch2.cc @@ -0,0 +1,83 @@ +#include "CommonTools/BaseParticlePropagator/interface/makeMuon.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + + +static constexpr const double kMuonMass = 0.10566; + +TEST_CASE("makeMuon tests", "[makeMuon]") { + SECTION("muon at rest") { + auto m1 = rawparticle::makeMuon(true,math::XYZTLorentzVector{}, math::XYZTLorentzVector{}); + + REQUIRE(m1.charge() == -1.); + REQUIRE(m1.mass() == kMuonMass); + REQUIRE(m1.px() == 0.); + REQUIRE(m1.py() == 0.); + REQUIRE(m1.pz() == 0.); + REQUIRE(m1.x() == 0.); + REQUIRE(m1.y() == 0.); + REQUIRE(m1.z() == 0.); + REQUIRE(m1.t() == 0.); + + //NOTE: energy is incorrectly calculated! + //REQUIRE(m1.e() == kMuonMass); + REQUIRE(m1.e() == 0.); + } + + SECTION("anti-muon at rest") { + auto m1 = rawparticle::makeMuon(false,math::XYZTLorentzVector{}, math::XYZTLorentzVector{}); + + REQUIRE(m1.charge() == 1.); + REQUIRE(m1.mass() == kMuonMass); + REQUIRE(m1.px() == 0.); + REQUIRE(m1.py() == 0.); + REQUIRE(m1.pz() == 0.); + REQUIRE(m1.x() == 0.); + REQUIRE(m1.y() == 0.); + REQUIRE(m1.z() == 0.); + REQUIRE(m1.t() == 0.); + + //NOTE: energy is incorrectly calculated! + //REQUIRE(m1.e() == kMuonMass); + REQUIRE(m1.e() == 0.); + } + + SECTION("muon at rest, transposed") { + auto m1 = rawparticle::makeMuon(true,math::XYZTLorentzVector{}, math::XYZTLorentzVector{1.,2.,3.,4.}); + + REQUIRE(m1.charge() == -1.); + REQUIRE(m1.mass() == kMuonMass); + REQUIRE(m1.px() == 0.); + REQUIRE(m1.py() == 0.); + REQUIRE(m1.pz() == 0.); + REQUIRE(m1.x() == 1.); + REQUIRE(m1.y() == 2.); + REQUIRE(m1.z() == 3.); + REQUIRE(m1.t() == 4.); + + //NOTE: energy is incorrectly calculated! + //REQUIRE(m1.e() == kMuonMass); + REQUIRE(m1.e() == 0.); + } + + SECTION("muon in motion") { + auto m1 = rawparticle::makeMuon(true,math::XYZTLorentzVector{1.,2.,3., 8.}, math::XYZTLorentzVector{}); + + REQUIRE(m1.charge() == -1.); + REQUIRE(m1.mass() == kMuonMass); + REQUIRE(m1.px() == 1.); + REQUIRE(m1.py() == 2.); + REQUIRE(m1.pz() == 3.); + REQUIRE(m1.x() == 0.); + REQUIRE(m1.y() == 0.); + REQUIRE(m1.z() == 0.); + REQUIRE(m1.t() == 0.); + + //NOTE: energy is incorrectly calculated! + //REQUIRE(m1.e() == sqrt(kMuonMass*kMuonMass+m1.px()*m1.px()+m1.py()*m1.py()+m1.pz()*m1.pz())); + REQUIRE(m1.e() == 8.); + } + +} diff --git a/CommonTools/ParticleFlow/python/pfTaus_cff.py b/CommonTools/ParticleFlow/python/pfTaus_cff.py index d4feec04989eb..bee25cf1b85bc 100644 --- a/CommonTools/ParticleFlow/python/pfTaus_cff.py +++ b/CommonTools/ParticleFlow/python/pfTaus_cff.py @@ -50,11 +50,14 @@ pfTausProducerSansRefs = cms.EDProducer( "RecoTauCleaner", src = cms.InputTag("pfTausCombiner"), + outputSelection = cms.string(""), + verbosity = cms.int32(0), cleaners = cms.VPSet( cleaners.unitCharge, cms.PSet( name = cms.string("leadStripPtLt2_5"), plugin = cms.string("RecoTauStringCleanerPlugin"), + tolerance = cleaners.tolerance_default, selection = cms.string("signalPiZeroCandidates().size() = 0 | signalPiZeroCandidates()[0].pt > 2.5"), selectionPassFunction = cms.string("0"), selectionFailValue = cms.double(1e3) @@ -62,6 +65,7 @@ cms.PSet( name = cms.string("HPS_Select"), plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), + tolerance = cleaners.tolerance_default, src = cms.InputTag("pfTausSelectionDiscriminator"), ), cleaners.combinedIsolation diff --git a/CommonTools/UtilAlgos/interface/SingleElementCollectionRefSelector.h b/CommonTools/UtilAlgos/interface/SingleElementCollectionRefSelector.h index a8fd89921f339..88a1945e5964c 100644 --- a/CommonTools/UtilAlgos/interface/SingleElementCollectionRefSelector.h +++ b/CommonTools/UtilAlgos/interface/SingleElementCollectionRefSelector.h @@ -53,7 +53,7 @@ struct SingleElementCollectionRefSelector { container selected_; selector select_; RefAdder addRef_; - friend class reco::modules::SingleElementCollectionRefSelectorEventSetupInit; + friend struct reco::modules::SingleElementCollectionRefSelectorEventSetupInit; }; #include "CommonTools/UtilAlgos/interface/EventSetupInitTrait.h" diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index dbe9d8628602f..2fe0ac1625e95 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -1,4 +1,6 @@ #include "CondCore/ESSources/interface/registration_macros.h" +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h" #include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h" @@ -12,6 +14,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h" +REGISTER_PLUGIN(CTPPSBeamParametersRcd,CTPPSBeamParameters); REGISTER_PLUGIN(CTPPSPixelDAQMappingRcd,CTPPSPixelDAQMapping); REGISTER_PLUGIN(CTPPSPixelAnalysisMaskRcd,CTPPSPixelAnalysisMask); REGISTER_PLUGIN(CTPPSPixelGainCalibrationsRcd,CTPPSPixelGainCalibrations); diff --git a/CondCore/SiPhase2TrackerPlugins/BuildFile.xml b/CondCore/SiPhase2TrackerPlugins/BuildFile.xml new file mode 100644 index 0000000000000..6eb280211be26 --- /dev/null +++ b/CondCore/SiPhase2TrackerPlugins/BuildFile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/CondCore/SiPhase2TrackerPlugins/src/plugin.cc b/CondCore/SiPhase2TrackerPlugins/src/plugin.cc new file mode 100644 index 0000000000000..b66c102c40d25 --- /dev/null +++ b/CondCore/SiPhase2TrackerPlugins/src/plugin.cc @@ -0,0 +1,6 @@ +#include "CondCore/PluginSystem/interface/registration_macros.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h" + +REGISTER_PLUGIN(TrackerDetToDTCELinkCablingMapRcd,TrackerDetToDTCELinkCablingMap); + diff --git a/CondCore/Utilities/BuildFile.xml b/CondCore/Utilities/BuildFile.xml index d9b6ce83a2351..b23be7ad383ab 100644 --- a/CondCore/Utilities/BuildFile.xml +++ b/CondCore/Utilities/BuildFile.xml @@ -5,6 +5,7 @@ + diff --git a/CondFormats/CTPPSReadoutObjects/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/BuildFile.xml index 9abcabe352d4b..247e1e31a67fe 100644 --- a/CondFormats/CTPPSReadoutObjects/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/BuildFile.xml @@ -1,10 +1,13 @@ + + + diff --git a/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h b/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h new file mode 100644 index 0000000000000..13e6dfe53b47c --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h @@ -0,0 +1,129 @@ +#ifndef CondFormats_CTPPSReadoutObjects_CTPPSBeamParameters_h +#define CondFormats_CTPPSReadoutObjects_CTPPSBeamParameters_h +// -*- C++ -*- +// +// Package: CTPPSReadoutObjects +// Class: CTPPSBeamParameters +// +/**\class CTPPSBeamParameters CTPPSBeamParameters.h CondFormats/CTPPSRedoutObjects/src/CTPPSBeamParameters.cc + + Description: Beam parameters for proton reconstruction + + Implementation: + +*/ +// Original Author: Wagner Carvalho +// Created: 20 Nov 2018 +// + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +class CTPPSBeamParameters { + + public: + + // Constructor + CTPPSBeamParameters() ; + // Destructor + ~CTPPSBeamParameters() ; + + // Getters + + double getBeamMom45() const ; + double getBeamMom56() const ; + + double getBetaStarX45() const ; + double getBetaStarY45() const ; + double getBetaStarX56() const ; + double getBetaStarY56() const ; + + double getBeamDivergenceX45() const ; + double getBeamDivergenceY45() const ; + double getBeamDivergenceX56() const ; + double getBeamDivergenceY56() const ; + + double getHalfXangleX45() const ; + double getHalfXangleY45() const ; + double getHalfXangleX56() const ; + double getHalfXangleY56() const ; + + double getVtxOffsetX45() const ; + double getVtxOffsetY45() const ; + double getVtxOffsetZ45() const ; + double getVtxOffsetX56() const ; + double getVtxOffsetY56() const ; + double getVtxOffsetZ56() const ; + + double getVtxStddevX() const ; + double getVtxStddevY() const ; + double getVtxStddevZ() const ; + + // Setters + + void setBeamMom45( double mom ) ; + void setBeamMom56( double mom ) ; + + void setBetaStarX45( double beta ) ; + void setBetaStarY45( double beta ) ; + void setBetaStarX56( double beta ) ; + void setBetaStarY56( double beta ) ; + + void setBeamDivergenceX45( double div ) ; + void setBeamDivergenceY45( double div ) ; + void setBeamDivergenceX56( double div ) ; + void setBeamDivergenceY56( double div ) ; + + void setHalfXangleX45( double angle ) ; + void setHalfXangleY45( double angle ) ; + void setHalfXangleX56( double angle ) ; + void setHalfXangleY56( double angle ) ; + + void setVtxOffsetX45( double offset ) ; + void setVtxOffsetY45( double offset ) ; + void setVtxOffsetZ45( double offset ) ; + void setVtxOffsetX56( double offset ) ; + void setVtxOffsetY56( double offset ) ; + void setVtxOffsetZ56( double offset ) ; + + void setVtxStddevX( double stddev ) ; + void setVtxStddevY( double stddev ) ; + void setVtxStddevZ( double stddev ) ; + + void printInfo(std::stringstream & s) ; + + + private: + + // LHC sector 45 corresponds to beam 2, sector 56 to beam 1 + double beam_momentum_45_ ; // GeV + double beam_momentum_56_ ; // GeV + + double beta_star_x_45_ , beta_star_x_56_; // cm + double beta_star_y_45_ , beta_star_y_56_; + + double beam_divergence_x_45_ , beam_divergence_x_56_ ; // rad + double beam_divergence_y_45_ , beam_divergence_y_56_ ; + + double half_crossing_angle_x_45_ , half_crossing_angle_x_56_ ; // rad + double half_crossing_angle_y_45_ , half_crossing_angle_y_56_ ; + + // splitting between 45 and 56 may effectively account for magnet misalignment + double vtx_offset_x_45_ , vtx_offset_x_56_ ; // cm + double vtx_offset_y_45_ , vtx_offset_y_56_ ; // cm + double vtx_offset_z_45_ , vtx_offset_z_56_ ; // cm + + // the following variables might possibly be in another CMS record already, + // but we might want to keep them for completeness/independence + double vtx_stddev_x_ ; // cm + double vtx_stddev_y_ ; // cm + double vtx_stddev_z_ ; // cm + + + COND_SERIALIZABLE; + +}; + +std::ostream & operator<<( std::ostream &, CTPPSBeamParameters ); + +#endif \ No newline at end of file diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h new file mode 100644 index 0000000000000..ad2682c7dc09a --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h @@ -0,0 +1,46 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSet_h +#define CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSet_h + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include "TSpline.h" + +class CTPPSInterpolatedOpticalFunctionsESSource; + +/// Set of optical functions corresponding to one scoring plane along LHC, including splines for interpolation performance. +class LHCInterpolatedOpticalFunctionsSet : public LHCOpticalFunctionsSet +{ + public: + LHCInterpolatedOpticalFunctionsSet() = default; + + LHCInterpolatedOpticalFunctionsSet(const LHCOpticalFunctionsSet &src) : LHCOpticalFunctionsSet(src) {} + + ~LHCInterpolatedOpticalFunctionsSet() = default; + + const std::vector>& splines() const { return m_splines; } + + /// builds splines from m_*_values fields + void initializeSplines(); + + /// proton kinematics description + struct Kinematics + { + double x; // physics vertex position (beam offset subtracted), cm + double th_x; // physics scattering angle (crossing angle subtracted), rad + double y; // physics vertex position, cm + double th_y; // physics scattering angle, rad + double xi; // relative momentum loss (positive for diffractive protons) + }; + + /// transports proton according to the splines + void transport(const Kinematics &input, Kinematics &output, bool calculateAngles = false) const; + + protected: + friend CTPPSInterpolatedOpticalFunctionsESSource; + + std::vector> m_splines; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h new file mode 100644 index 0000000000000..fff9cac3fc38f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h @@ -0,0 +1,14 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSetCollection_h +#define CondFormats_CTPPSReadoutObjects_LHCInterpolatedOpticalFunctionsSetCollection_h + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" + +#include + +class LHCInterpolatedOpticalFunctionsSetCollection : public std::unordered_map +{ +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h new file mode 100644 index 0000000000000..1b45ae179910c --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h @@ -0,0 +1,42 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h +#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSet_h + +#include "CondFormats/Serialization/interface/Serializable.h" + +#include +#include +#include + +/// Set of optical functions corresponding to one scoring plane along LHC. +class LHCOpticalFunctionsSet +{ + public: + /// indices for m_fcn_values and m_splines data members + enum { evx, eLx, e14, exd, evpx, eLpx, e24, expd, e32, evy, eLy, eyd, e42, evpy, eLpy, eypd, nFunctions }; + + LHCOpticalFunctionsSet() = default; + + /// fills m_*_values fields from a ROOT file + LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, double z); + + ~LHCOpticalFunctionsSet() = default; + + /// returns the position of the scoring plane (LHC/TOTEM convention) + double getScoringPlaneZ() const { return m_z; } + + const std::vector& getXiValues() const { return m_xi_values; } + const std::vector>& getFcnValues() const { return m_fcn_values; } + + protected: + /// position of the scoring plane, in LHC/TOTEM convention, cm + double m_z; + + std::vector m_xi_values; + std::vector> m_fcn_values; ///< length unit cm + + COND_SERIALIZABLE; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h new file mode 100644 index 0000000000000..d7529cdbb85bc --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h @@ -0,0 +1,22 @@ +// Original Author: Jan Kašpar + +#ifndef CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSetCollection_h +#define CondFormats_CTPPSReadoutObjects_LHCOpticalFunctionsSetCollection_h + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include +#include + +/** + \brief Collection of optical functions for two crossing angle values and various scoring planes. + * map: crossing angle --> (map: RP id --> optical functions) +**/ +class LHCOpticalFunctionsSetCollection : public std::map> +{ + private: + COND_SERIALIZABLE; +}; + +#endif diff --git a/CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h b/CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h index 78a9d43bcce50..228b714535eda 100644 --- a/CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h +++ b/CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h @@ -39,10 +39,10 @@ class PPSTimingCalibration formula_( formula ), parameters_( params ), timeInfo_( timeinfo ) {} ~PPSTimingCalibration() = default; - std::vector parameters( int db, int sampic, int channel, int cell ) const; + std::vector parameters( int key1, int key2, int key3, int key4 ) const; inline const std::string& formula() const { return formula_; } - double timeOffset( int db, int sampic, int channel ) const; - double timePrecision( int db, int sampic, int channel ) const; + double timeOffset( int key1, int key2, int key3, int key4 = -1 ) const; + double timePrecision( int key1, int key2, int key3, int key4 = -1 ) const; friend std::ostream& operator<<( std::ostream& os, const PPSTimingCalibration& data ); diff --git a/CondFormats/CTPPSReadoutObjects/python/PPSTimingDetEnum_cff.py b/CondFormats/CTPPSReadoutObjects/python/PPSTimingDetEnum_cff.py new file mode 100644 index 0000000000000..f29926421b430 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/python/PPSTimingDetEnum_cff.py @@ -0,0 +1,5 @@ +class PPSTimingDetEnum: + INVALID = 0 + TOTEM_UFSD = 1 + PPS_DIAMOND = 2 + diff --git a/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc new file mode 100644 index 0000000000000..2b0d122c9e9f6 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/CTPPSBeamParameters.cc @@ -0,0 +1,137 @@ +// -*- C++ -*- +// +// Package: CTPPSReadoutObjects +// Class: CTPPSBeamParameters +// +/**\class CTPPSBeamParameters CTPPSBeamParameters.h CondFormats/CTPPSRedoutObjects/src/CTPPSBeamParameters.cc + + Description: Beam parameters for proton reconstruction + + Implementation: + +*/ +// Original Author: Wagner Carvalho +// Created: 20 Nov 2018 +// + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include + + // Constructors + + CTPPSBeamParameters::CTPPSBeamParameters() : + beam_momentum_45_ (0.) , beam_momentum_56_ (0.) , + beta_star_x_45_ (0.) , beta_star_x_56_ (0.) , + beta_star_y_45_ (0.) , beta_star_y_56_ (0.) , + beam_divergence_x_45_ (0.) , beam_divergence_x_56_ (0.) , + beam_divergence_y_45_ (0.) , beam_divergence_y_56_ (0.) , + half_crossing_angle_x_45_ (0.) , half_crossing_angle_x_56_ (0.) , + half_crossing_angle_y_45_ (0.) , half_crossing_angle_y_56_ (0.) , + vtx_offset_x_45_ (0.) , vtx_offset_x_56_ (0.) , + vtx_offset_y_45_ (0.) , vtx_offset_y_56_ (0.) , + vtx_offset_z_45_ (0.) , vtx_offset_z_56_ (0.) , + vtx_stddev_x_ (0.) , vtx_stddev_y_ (0.) , vtx_stddev_z_ (0.) + {} + + // Destructor + CTPPSBeamParameters::~CTPPSBeamParameters() {} + + // Getters + + double CTPPSBeamParameters::getBeamMom45() const {return beam_momentum_45_;} + double CTPPSBeamParameters::getBeamMom56() const {return beam_momentum_56_;} + + double CTPPSBeamParameters::getBetaStarX45() const {return beta_star_x_45_;} + double CTPPSBeamParameters::getBetaStarY45() const {return beta_star_y_45_;} + double CTPPSBeamParameters::getBetaStarX56() const {return beta_star_x_56_;} + double CTPPSBeamParameters::getBetaStarY56() const {return beta_star_y_56_;} + + double CTPPSBeamParameters::getBeamDivergenceX45() const {return beam_divergence_x_45_;} + double CTPPSBeamParameters::getBeamDivergenceY45() const {return beam_divergence_y_45_;} + double CTPPSBeamParameters::getBeamDivergenceX56() const {return beam_divergence_x_56_;} + double CTPPSBeamParameters::getBeamDivergenceY56() const {return beam_divergence_y_56_;} + + double CTPPSBeamParameters::getHalfXangleX45() const {return half_crossing_angle_x_45_;} + double CTPPSBeamParameters::getHalfXangleY45() const {return half_crossing_angle_y_45_;} + double CTPPSBeamParameters::getHalfXangleX56() const {return half_crossing_angle_x_56_;} + double CTPPSBeamParameters::getHalfXangleY56() const {return half_crossing_angle_y_56_;} + + double CTPPSBeamParameters::getVtxOffsetX45() const {return vtx_offset_x_45_;} + double CTPPSBeamParameters::getVtxOffsetY45() const {return vtx_offset_y_45_;} + double CTPPSBeamParameters::getVtxOffsetZ45() const {return vtx_offset_z_45_;} + double CTPPSBeamParameters::getVtxOffsetX56() const {return vtx_offset_x_56_;} + double CTPPSBeamParameters::getVtxOffsetY56() const {return vtx_offset_y_56_;} + double CTPPSBeamParameters::getVtxOffsetZ56() const {return vtx_offset_z_56_;} + + double CTPPSBeamParameters::getVtxStddevX() const {return vtx_stddev_x_;} + double CTPPSBeamParameters::getVtxStddevY() const {return vtx_stddev_y_;} + double CTPPSBeamParameters::getVtxStddevZ() const {return vtx_stddev_z_;} + + // Setters + + void CTPPSBeamParameters::setBeamMom45( double mom ) {beam_momentum_45_ = mom;} + void CTPPSBeamParameters::setBeamMom56( double mom ) {beam_momentum_56_ = mom;} + + void CTPPSBeamParameters::setBetaStarX45( double beta ) {beta_star_x_45_ = beta;} + void CTPPSBeamParameters::setBetaStarY45( double beta ) {beta_star_y_45_ = beta;} + void CTPPSBeamParameters::setBetaStarX56( double beta ) {beta_star_x_56_ = beta;} + void CTPPSBeamParameters::setBetaStarY56( double beta ) {beta_star_y_56_ = beta;} + + void CTPPSBeamParameters::setBeamDivergenceX45( double div ) {beam_divergence_x_45_ = div;} + void CTPPSBeamParameters::setBeamDivergenceY45( double div ) {beam_divergence_y_45_ = div;} + void CTPPSBeamParameters::setBeamDivergenceX56( double div ) {beam_divergence_x_56_ = div;} + void CTPPSBeamParameters::setBeamDivergenceY56( double div ) {beam_divergence_y_56_ = div;} + + void CTPPSBeamParameters::setHalfXangleX45( double angle ) {half_crossing_angle_x_45_ = angle;} + void CTPPSBeamParameters::setHalfXangleY45( double angle ) {half_crossing_angle_y_45_ = angle;} + void CTPPSBeamParameters::setHalfXangleX56( double angle ) {half_crossing_angle_x_56_ = angle;} + void CTPPSBeamParameters::setHalfXangleY56( double angle ) {half_crossing_angle_y_56_ = angle;} + + void CTPPSBeamParameters::setVtxOffsetX45( double offset ) {vtx_offset_x_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetY45( double offset ) {vtx_offset_y_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetZ45( double offset ) {vtx_offset_z_45_ = offset;} + void CTPPSBeamParameters::setVtxOffsetX56( double offset ) {vtx_offset_x_56_ = offset;} + void CTPPSBeamParameters::setVtxOffsetY56( double offset ) {vtx_offset_y_56_ = offset;} + void CTPPSBeamParameters::setVtxOffsetZ56( double offset ) {vtx_offset_z_56_ = offset;} + + void CTPPSBeamParameters::setVtxStddevX( double stddev ) {vtx_stddev_x_ = stddev;} + void CTPPSBeamParameters::setVtxStddevY( double stddev ) {vtx_stddev_y_ = stddev;} + void CTPPSBeamParameters::setVtxStddevZ( double stddev ) {vtx_stddev_z_ = stddev;} + + + void CTPPSBeamParameters::printInfo(std::stringstream & s) + { + s << "\n Beam parameters : \n" + << "\n beam_momentum_45 = " << beam_momentum_45_ << " GeV" + << "\n beam_momentum_56 = " << beam_momentum_56_ << " GeV" + << "\n beta_star_x_45 = " << beta_star_x_45_ << " cm" + << "\n beta_star_y_45 = " << beta_star_y_45_ << " cm" + << "\n beta_star_x_56 = " << beta_star_x_56_ << " cm" + << "\n beta_star_y_56 = " << beta_star_y_56_ << " cm" + << "\n beam_divergence_x_45 = " << beam_divergence_x_45_ << " rad" + << "\n beam_divergence_y_45 = " << beam_divergence_y_45_ << " rad" + << "\n beam_divergence_x_56 = " << beam_divergence_x_56_ << " rad" + << "\n beam_divergence_y_56 = " << beam_divergence_y_56_ << " rad" + << "\n half_crossing_angle_x_45 = " << half_crossing_angle_x_45_ << " rad" + << "\n half_crossing_angle_y_45 = " << half_crossing_angle_y_45_ << " rad" + << "\n half_crossing_angle_x_56 = " << half_crossing_angle_x_56_ << " rad" + << "\n half_crossing_angle_y_56 = " << half_crossing_angle_y_56_ << " rad" + << "\n vtx_offset_x_45 = " << vtx_offset_x_45_ << " cm" + << "\n vtx_offset_y_45 = " << vtx_offset_y_45_ << " cm" + << "\n vtx_offset_z_45 = " << vtx_offset_z_45_ << " cm" + << "\n vtx_offset_x_56 = " << vtx_offset_x_56_ << " cm" + << "\n vtx_offset_y_56 = " << vtx_offset_y_56_ << " cm" + << "\n vtx_offset_z_56 = " << vtx_offset_z_56_ << " cm" + << "\n vtx_stddev_x = " << vtx_stddev_x_ << " cm" + << "\n vtx_stddev_y = " << vtx_stddev_y_ << " cm" + << "\n vtx_stddev_z = " << vtx_stddev_z_ << " cm" + << std::endl ; + + } + +std::ostream & operator<<( std::ostream & os, CTPPSBeamParameters info ) { + std::stringstream ss; + info.printInfo( ss ); + os << ss.str(); + return os; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..0730ad0c7f81f --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/LHCInterpolatedOpticalFunctionsSet.cc @@ -0,0 +1,36 @@ +// Original Author: Jan Kašpar + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" + +//---------------------------------------------------------------------------------------------------- + +void LHCInterpolatedOpticalFunctionsSet::initializeSplines() +{ + const unsigned int num_xi_vals = m_xi_values.size(); + + m_splines.resize(m_fcn_values.size()); + for (unsigned int i = 0; i < m_fcn_values.size(); ++i) + m_splines[i] = std::make_shared("", m_xi_values.data(), m_fcn_values[i].data(), num_xi_vals); +} + +//---------------------------------------------------------------------------------------------------- + +void LHCInterpolatedOpticalFunctionsSet::transport(const LHCInterpolatedOpticalFunctionsSet::Kinematics &input, + LHCInterpolatedOpticalFunctionsSet::Kinematics &output, bool calculateAngles) const +{ + const double xi = input.xi; + + output.x = m_splines[exd]->Eval(xi) + m_splines[evx]->Eval(xi) * input.x + + m_splines[eLx]->Eval(xi) * input.th_x + m_splines[e14]->Eval(xi) * input.th_y; + + output.th_x = (!calculateAngles) ? 0. : m_splines[expd]->Eval(xi) + m_splines[evpx]->Eval(xi) * input.x + + m_splines[eLpx]->Eval(xi) * input.th_x + m_splines[e24]->Eval(xi) * input.th_y; + + output.y = m_splines[eyd]->Eval(xi) + m_splines[evy]->Eval(xi) * input.y + + m_splines[eLy]->Eval(xi) * input.th_y + m_splines[e32]->Eval(xi) * input.th_x; + + output.th_y = (!calculateAngles) ? 0. : m_splines[eypd]->Eval(xi) + m_splines[evpy]->Eval(xi) * input.y + + m_splines[eLpy]->Eval(xi) * input.th_y + m_splines[e42]->Eval(xi) * input.th_x; + + output.xi = input.xi; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..7d29c319a4ed6 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/LHCOpticalFunctionsSet.cc @@ -0,0 +1,68 @@ +// Original Author: Jan Kašpar + +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" + +#include "FWCore/Utilities/interface/Exception.h" + +#include "TFile.h" +#include "TGraph.h" + +//---------------------------------------------------------------------------------------------------- + +LHCOpticalFunctionsSet::LHCOpticalFunctionsSet(const std::string &fileName, const std::string &directoryName, double z) : + m_z(z) +{ + TFile *f_in = TFile::Open(fileName.c_str()); + if (f_in == nullptr) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot open file " << fileName << "."; + + std::vector graphs(nFunctions); + for (unsigned int fi = 0; fi < nFunctions; ++fi) + { + std::string tag; + if (fi == evx) tag = "v_x"; + else if (fi == eLx) tag = "L_x"; + else if (fi == e14) tag = "E_14"; + else if (fi == exd) tag = "x_D"; + else if (fi == evpx) tag = "vp_x"; + else if (fi == eLpx) tag = "Lp_x"; + else if (fi == e24) tag = "E_24"; + else if (fi == expd) tag = "xp_D"; + else if (fi == e32) tag = "E_32"; + else if (fi == evy) tag = "v_y"; + else if (fi == eLy) tag = "L_y"; + else if (fi == eyd) tag = "y_D"; + else if (fi == e42) tag = "E_42"; + else if (fi == evpy) tag = "vp_y"; + else if (fi == eLpy) tag = "Lp_y"; + else if (fi == eypd) tag = "yp_D"; + else + throw cms::Exception("LHCOpticalFunctionsSet") << "Invalid tag for optical functions: \"" << fi << "\""; + + std::string objPath = directoryName + "/g_" + tag + "_vs_xi"; + auto gr_obj = dynamic_cast( f_in->Get(objPath.c_str()) ); + if (!gr_obj) + throw cms::Exception("LHCOpticalFunctionsSet") << "Cannot load object " << objPath << " from file " << fileName << "."; + + graphs[fi] = gr_obj; + } + + const unsigned int num_xi_vals = graphs[0]->GetN(); + m_xi_values.resize(num_xi_vals); + + m_fcn_values.resize(nFunctions); + + for (unsigned int fi = 0; fi < nFunctions; ++fi) + m_fcn_values[fi].resize(num_xi_vals); + + for (unsigned int pi = 0; pi < num_xi_vals; ++pi) + { + const double xi = graphs[0]->GetX()[pi]; + m_xi_values[pi] = xi; + + for (unsigned int fi = 0; fi < m_fcn_values.size(); ++fi) + m_fcn_values[fi][pi] = graphs[fi]->Eval(xi); + } + + delete f_in; +} diff --git a/CondFormats/CTPPSReadoutObjects/src/PPSTimingCalibration.cc b/CondFormats/CTPPSReadoutObjects/src/PPSTimingCalibration.cc index 3505b31bc6518..58333cb753a5a 100644 --- a/CondFormats/CTPPSReadoutObjects/src/PPSTimingCalibration.cc +++ b/CondFormats/CTPPSReadoutObjects/src/PPSTimingCalibration.cc @@ -34,9 +34,9 @@ operator<<( std::ostream& os, const PPSTimingCalibration::Key& key ) //-------------------------------------------------------------------------- std::vector -PPSTimingCalibration::parameters( int db, int sampic, int channel, int cell ) const +PPSTimingCalibration::parameters( int key1, int key2, int key3, int key4 ) const { - Key key{ db, sampic, channel, cell }; + Key key{ key1, key2, key3, key4 }; auto out = parameters_.find( key ); if ( out == parameters_.end() ) return {}; @@ -44,9 +44,9 @@ PPSTimingCalibration::parameters( int db, int sampic, int channel, int cell ) co } double -PPSTimingCalibration::timeOffset( int db, int sampic, int channel ) const +PPSTimingCalibration::timeOffset( int key1, int key2, int key3, int key4 ) const { - Key key{ db, sampic, channel, -1 }; + Key key{ key1, key2, key3, key4 }; auto out = timeInfo_.find( key ); if ( out == timeInfo_.end() ) return 0.; @@ -54,9 +54,9 @@ PPSTimingCalibration::timeOffset( int db, int sampic, int channel ) const } double -PPSTimingCalibration::timePrecision( int db, int sampic, int channel ) const +PPSTimingCalibration::timePrecision( int key1, int key2, int key3, int key4 ) const { - Key key{ db, sampic, channel, -1 }; + Key key{ key1, key2, key3, key4 }; auto out = timeInfo_.find( key ); if ( out == timeInfo_.end() ) return 0.; @@ -71,9 +71,7 @@ operator<<( std::ostream& os, const PPSTimingCalibration& data ) os << kv.first <<" ["; for ( size_t i = 0; i < kv.second.size(); ++i ) os << ( i > 0 ? ", " : "" ) << kv.second.at( i ); - PPSTimingCalibration::Key k = kv.first; - k.cell = -1; - const auto& time = data.timeInfo_.at( k ); + const auto& time = data.timeInfo_.at( kv.first ); os << "] " << time.first << " " << time.second << "\n"; } return os; diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc new file mode 100644 index 0000000000000..07fac4921dd76 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_CTPPSBeamParameters.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(CTPPSBeamParameters); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..1a2798e54ba97 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSet.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInterpolatedOpticalFunctionsSet); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc new file mode 100644 index 0000000000000..bf10004105613 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCInterpolatedOpticalFunctionsSetCollection.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInterpolatedOpticalFunctionsSetCollection); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc new file mode 100644 index 0000000000000..25799a9eda263 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSet.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCOpticalFunctionsSet); diff --git a/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc new file mode 100644 index 0000000000000..ce0e1a898f353 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/src/T_EventSetup_LHCOpticalFunctionsSetCollection.cc @@ -0,0 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCOpticalFunctionsSetCollection); diff --git a/CondFormats/CTPPSReadoutObjects/src/classes.h b/CondFormats/CTPPSReadoutObjects/src/classes.h index b7ca13560a193..89a64917e3daa 100644 --- a/CondFormats/CTPPSReadoutObjects/src/classes.h +++ b/CondFormats/CTPPSReadoutObjects/src/classes.h @@ -1,18 +1,24 @@ #include "CondFormats/CTPPSReadoutObjects/src/headers.h" namespace CondFormats_CTPPSPixelObjects { - struct dictionary { - std::map ROCMapping; - std::map analysisMask; - std::vector< CTPPSPixelGainCalibration::DetRegistry >::iterator p3; - std::vector< CTPPSPixelGainCalibration::DetRegistry >::const_iterator p4; - std::map mycalibmap; - std::map mapType; - //--- timing calibration parameters - std::map > tc_tm; - std::map > tc_pm; - std::pair > tc_v_tm; - std::pair > tc_v_pm; + struct dictionary { + std::map ROCMapping; + std::map analysisMask; + std::vector< CTPPSPixelGainCalibration::DetRegistry >::iterator p3; + std::vector< CTPPSPixelGainCalibration::DetRegistry >::const_iterator p4; + std::map mycalibmap; + std::map mapType; + + //--- timing calibration parameters + std::map > tc_tm; + std::map > tc_pm; + std::pair > tc_v_tm; + std::pair > tc_v_pm; + + LHCOpticalFunctionsSet lhc_ofs; + LHCOpticalFunctionsSetCollection lhc_ofsc; + LHCInterpolatedOpticalFunctionsSet lhc_iofs; + LHCInterpolatedOpticalFunctionsSetCollection lhc_iofsc; }; } diff --git a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml index 77ac92b1126e8..522f9de2cd61d 100644 --- a/CondFormats/CTPPSReadoutObjects/src/classes_def.xml +++ b/CondFormats/CTPPSReadoutObjects/src/classes_def.xml @@ -1,4 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,5 +61,10 @@ + + + + + diff --git a/CondFormats/CTPPSReadoutObjects/src/headers.h b/CondFormats/CTPPSReadoutObjects/src/headers.h index 733a7e89b1135..2b74cd572dc5f 100644 --- a/CondFormats/CTPPSReadoutObjects/src/headers.h +++ b/CondFormats/CTPPSReadoutObjects/src/headers.h @@ -1,3 +1,4 @@ +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelDAQMapping.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelAnalysisMask.h" #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSPixelGainCalibrations.h" @@ -5,3 +6,7 @@ #include "CondFormats/CTPPSReadoutObjects/interface/CTPPSRPAlignmentCorrectionsDataSequence.h" #include "CondFormats/CTPPSReadoutObjects/interface/PPSTimingCalibration.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCOpticalFunctionsSetCollection.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" diff --git a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml index d798a922007da..f925e58a4f741 100644 --- a/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml +++ b/CondFormats/CTPPSReadoutObjects/test/BuildFile.xml @@ -1,7 +1,7 @@ - - - + + + diff --git a/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc b/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc new file mode 100644 index 0000000000000..b9b3ec427bf76 --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/test/testSerializationBeamParameters.cc @@ -0,0 +1,9 @@ +#include "CondFormats/Serialization/interface/Test.h" +#include "CondFormats/CTPPSReadoutObjects/src/headers.h" + +int main() +{ + testSerialization() ; + + return 0 ; +} diff --git a/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py b/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py new file mode 100644 index 0000000000000..d31be1e81c0eb --- /dev/null +++ b/CondFormats/CTPPSReadoutObjects/test/test_BeamParametersESSource.py @@ -0,0 +1,76 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ) +) + +# raw data source +#process.source = cms.Source("EmptySource", +#) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + # timetype = cms.string('lumiid'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# Load beam parameters +process.load("CondFormats.CTPPSReadoutObjects.CTPPSBeamParametersESSource_cfi") +# process.CTPPSBeamParametersESSource.verbosity = cms.untracked.uint32(2) + +# Test retrieving the ESSource data +process.get = cms.EDAnalyzer("RetrieveCTPPSBeamParameters", + verbose = cms.untracked.bool(True) +) + +# ======================== Test writing to DB ========================================== + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# Output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + # timetype = cms.untracked.string('timestamp'), + # timetype = cms.untracked.string('lumiid'), + toPut = cms.VPSet( + cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string('CTPPSBeamParameters_v1') + ) + ) +) + +process.write = cms.EDAnalyzer("WriteCTPPSBeamParameters", + record = cms.string('CTPPSBeamParametersRcd'), + loggingOn= cms.untracked.bool(True), + SinceAppendMode=cms.bool(True), + Source=cms.PSet( + IOVRun=cms.untracked.uint32(1) + ) +) + +# =============================================================================== + + +process.path = cms.Path( + process.get*process.write +) diff --git a/CondFormats/DataRecord/BuildFile.xml b/CondFormats/DataRecord/BuildFile.xml index d2481fce20d26..b51598703838c 100644 --- a/CondFormats/DataRecord/BuildFile.xml +++ b/CondFormats/DataRecord/BuildFile.xml @@ -1,6 +1,5 @@ - diff --git a/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h b/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h new file mode 100644 index 0000000000000..3739d19fbc29e --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h @@ -0,0 +1,25 @@ +#ifndef CTPPSBeamParametersRcd_CTPPSBeamParametersRcd_h +#define CTPPSBeamParametersRcd_CTPPSBeamParametersRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : CTPPSBeamParametersRcd +// +/**\class CTPPSBeamParametersRcd CTPPSBeamParametersRcd.h CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h + + Description: Record for beam parameters for CTPPS + + Usage: + + +*/ +// +// Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 16:12:53 GMT +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class CTPPSBeamParametersRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h b/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h new file mode 100644 index 0000000000000..b83de7df2140f --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h @@ -0,0 +1,17 @@ +// Author: Jan Kašpar + +#ifndef CondFormats_DataRecord_CTPPSInterpolatedOpticsRcd_h +#define CondFormats_DataRecord_CTPPSInterpolatedOpticsRcd_h + +#include "FWCore/Framework/interface/DependentRecordImplementation.h" + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "boost/mpl/vector.hpp" + +class CTPPSInterpolatedOpticsRcd : public edm::eventsetup::DependentRecordImplementation> +{ +}; + +#endif diff --git a/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h new file mode 100644 index 0000000000000..a91e7fbb021f8 --- /dev/null +++ b/CondFormats/DataRecord/interface/CTPPSOpticsRcd.h @@ -0,0 +1,10 @@ +// Author: Jan Kašpar + +#ifndef CondFormats_DataRecord_CTPPSOpticsRcd_h +#define CondFormats_DataRecord_CTPPSOpticsRcd_h + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class CTPPSOpticsRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h b/CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h new file mode 100644 index 0000000000000..e7bb67cd9471f --- /dev/null +++ b/CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h @@ -0,0 +1,25 @@ +#ifndef CondFormats_DataRecord_TrackerDetToDTCELinkCablingMapRcd_h +#define CondFormats_DataRecord_TrackerDetToDTCELinkCablingMapRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : TrackerDetToDTCELinkCablingMapRcd +// +/**\class TrackerDetToDTCELinkCablingMapRcd TrackerDetToDTCELinkCablingMapRcd.h CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMapRcd.h + + Description: [one line class summary] + + Usage: + + +*/ +// +// Original Author: Luigi Calligaris, SPRACE, Sao Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class TrackerDetToDTCELinkCablingMapRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc b/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc new file mode 100644 index 0000000000000..65c374bbe8e72 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSBeamParametersRcd.cc @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : CTPPSBeamParametersRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 16:12:53 GMT + +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSBeamParametersRcd); diff --git a/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc b/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc new file mode 100644 index 0000000000000..1baa6a2a3f466 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSInterpolatedOpticsRcd.cc @@ -0,0 +1,6 @@ +// Author: Jan Kašpar + +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSInterpolatedOpticsRcd); diff --git a/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc b/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc new file mode 100644 index 0000000000000..6c39a25e99604 --- /dev/null +++ b/CondFormats/DataRecord/src/CTPPSOpticsRcd.cc @@ -0,0 +1,6 @@ +// Author: Jan Kašpar + +#include "CondFormats/DataRecord/interface/CTPPSOpticsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(CTPPSOpticsRcd); diff --git a/CondFormats/DataRecord/src/TrackerDetToDTCELinkCablingMapRcd.cc b/CondFormats/DataRecord/src/TrackerDetToDTCELinkCablingMapRcd.cc new file mode 100644 index 0000000000000..238c249e7a912 --- /dev/null +++ b/CondFormats/DataRecord/src/TrackerDetToDTCELinkCablingMapRcd.cc @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : TrackerDetToDTCELinkCablingMapRcd +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Luigi Calligaris, SPRACE, Sao Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT + +#include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(TrackerDetToDTCELinkCablingMapRcd); diff --git a/CondFormats/GEMObjects/interface/GEMDeadStrips.h b/CondFormats/GEMObjects/interface/GEMDeadStrips.h index ecb72b0f03f70..5ffd45632c731 100644 --- a/CondFormats/GEMObjects/interface/GEMDeadStrips.h +++ b/CondFormats/GEMObjects/interface/GEMDeadStrips.h @@ -18,6 +18,7 @@ class GEMDeadStrips { ~GEMDeadStrips(){} std::vector const & getDeadVec() const {return deadVec_;} + void fillDeadVec(DeadItem m) {deadVec_.push_back(m);} private: std::vector deadVec_; diff --git a/CondFormats/GEMObjects/interface/GEMMaskedStrips.h b/CondFormats/GEMObjects/interface/GEMMaskedStrips.h index 9b49cac3c9c35..8cadd0869fc64 100644 --- a/CondFormats/GEMObjects/interface/GEMMaskedStrips.h +++ b/CondFormats/GEMObjects/interface/GEMMaskedStrips.h @@ -18,6 +18,7 @@ class GEMMaskedStrips { ~GEMMaskedStrips(){} std::vector const & getMaskVec() const {return maskVec_;} + void fillMaskVec(MaskItem m) {maskVec_.push_back(m);} private: std::vector maskVec_; diff --git a/CondFormats/GEMObjects/test/test_serialization.cpp b/CondFormats/GEMObjects/test/test_serialization.cpp index f22e994bcbe1b..5a43213f16413 100644 --- a/CondFormats/GEMObjects/test/test_serialization.cpp +++ b/CondFormats/GEMObjects/test/test_serialization.cpp @@ -16,4 +16,9 @@ int main() testSerialization>(); testSerialization(); testSerialization>(); + + testSerialization(); + testSerialization(); + testSerialization(); + testSerialization(); } diff --git a/CondFormats/SiPhase2TrackerObjects/BuildFile.xml b/CondFormats/SiPhase2TrackerObjects/BuildFile.xml new file mode 100644 index 0000000000000..ae4fa2b527f1b --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h b/CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h new file mode 100644 index 0000000000000..542056e7072c2 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h @@ -0,0 +1,79 @@ +#ifndef CondFormats_Phase2TrackerDTC_DTCELinkId_h +#define CondFormats_Phase2TrackerDTC_DTCELinkId_h + +// -*- C++ -*- +// +// Package: CondFormats/Phase2TrackerDTC +// Class: DTCELinkId +// +/**\class DTCELinkId DTCELinkId.cc CondFormats/Phase2TrackerDTC/src/DTCELinkId.cc + +Description: DTCELinkId identifies a specific eLink in the interface of a specific GBT link instance in the firmware of a specific DTC of the tracker back-end. + +Implementation: + [Notes on implementation] +*/ +// +// Original Author: Luigi Calligaris, SPRACE, Sao Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// +// + +#include +#include + +#include "CondFormats/Serialization/interface/Serializable.h" + +class DTCELinkId +{ +public: + DTCELinkId() noexcept; + DTCELinkId(DTCELinkId const&) noexcept; + DTCELinkId(DTCELinkId&&) noexcept; + DTCELinkId& operator=(DTCELinkId const&) noexcept; + DTCELinkId& operator=(DTCELinkId&&) noexcept; + ~DTCELinkId() noexcept; + + // Constructs a DTCELinkId addressed by (dtc_id, gbtlink_id, elink_id) + DTCELinkId(uint16_t,uint8_t,uint8_t) noexcept; + + inline auto elink_id() const noexcept {return elink_id_ ;} + inline auto gbtlink_id() const noexcept {return gbtlink_id_;} + inline auto dtc_id() const noexcept {return dtc_id_ ;} + +private: + // In order to keep the payload small, we use the C standard integers, optimizing them for size. + // The lpGBT has at most 7 ePorts, therefore they can be addressed by an 8-bit number. + // The DTC should host at most 72 GBT links, therefore an 8-bit number should be enough to address it. + // The C++ memory alignment and padding rules impose that this class will have at least 32 bits size, + // i.e. 8+8+8 bits and 8+8+16 would be the same, so we choose the latter. + uint8_t elink_id_ ; + uint8_t gbtlink_id_; + uint16_t dtc_id_ ; + + COND_SERIALIZABLE; +}; + +namespace std +{ + template <> + struct hash + { + size_t operator()(const DTCELinkId& k) const noexcept + { + // With + constexpr const size_t shift_gbtlink_id = numeric_limits< decltype( k.elink_id() ) >::max() + 1u; + constexpr const size_t shift_dtc_id = (numeric_limits< decltype( k.gbtlink_id() ) >::max() + 1u) * shift_gbtlink_id; + + return k.elink_id() + k.gbtlink_id() * shift_gbtlink_id + k.dtc_id() * shift_dtc_id; + } + }; +} + +inline bool operator< (DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() < rhs.dtc_id() || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() < rhs.gbtlink_id()) || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() < rhs.elink_id());} +inline bool operator> (DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() > rhs.dtc_id() || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() > rhs.gbtlink_id()) || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() > rhs.elink_id());} +inline bool operator==(DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() == rhs.elink_id();} +inline bool operator!=(DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() != rhs.dtc_id() || lhs.gbtlink_id() != rhs.gbtlink_id() || lhs.elink_id() != rhs.elink_id();} + + +#endif // end DataFormats_Phase2TrackerDTC_DTCELinkId_h diff --git a/CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h b/CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h new file mode 100644 index 0000000000000..6efc643b2deb0 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h @@ -0,0 +1,72 @@ +#ifndef CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h +#define CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h + +// -*- C++ -*- +// +// Package: CondFormats/Phase2TrackerDTC +// Class: TrackerDetToDTCELinkCablingMap +// +/**\class TrackerDetToDTCELinkCablingMap TrackerDetToDTCELinkCablingMap.cc CondFormats/Phase2TrackerDTC/src/TrackerDetToDTCELinkCablingMap.cc + +Description: Map associating DTCELinkId of Phase2 tracker DTCs to DetId of the sensors connected to each of them. + +Implementation: + [Notes on implementation] +*/ +// +// Original Author: Luigi Calligaris, SPRACE, Sao Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// +// + +#include +#include +#include + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" + +class TrackerDetToDTCELinkCablingMap +{ + public: + TrackerDetToDTCELinkCablingMap(); + virtual ~TrackerDetToDTCELinkCablingMap(); + + /// Resolves the raw DetId of the detector connected to the eLink identified by a DTCELinkId + std::unordered_map::const_iterator dtcELinkIdToDetId(DTCELinkId const&) const; + + /// Resolves one or more DTCELinkId of eLinks which are connected to the detector identified by the given raw DetId + std::pair< std::unordered_multimap::const_iterator, std::unordered_multimap::const_iterator > detIdToDTCELinkId(uint32_t const) const; + + /// Returns true if the cabling map has a record corresponding to a detector identified by the given raw DetId + bool knowsDTCELinkId(DTCELinkId const&) const; + + /// Returns true if the cabling map has a record corresponding to an eLink identified by the given DTCELinkId + bool knowsDetId(uint32_t) const; + + // IMPORTANT: The following information is not stored, to preserve space in memory. + // As these vectors are generated each time the functions are called, you are encouraged to + // either cache the results or avoid calling them in hot loops. + // NOTE: This vectors are unsorted + + /// Returns a vector containing all elink DTCELinkId nown to the map + std::vector getKnownDTCELinkIds() const; + + /// Returns a vector containing all detector DetId known to the map + std::vector getKnownDetIds() const; + + + /// Inserts in the cabling map a record corresponding to the connection of an eLink identified by the given DTCELinkId to a detector identified by the given raw DetId + void insert(DTCELinkId const&, uint32_t const); + + /// Clears the map + void clear(); + + private: + std::unordered_multimap cablingMapDetIdToDTCELinkId_; + std::unordered_map cablingMapDTCELinkIdToDetId_; + + COND_SERIALIZABLE; +}; + +#endif // end CondFormats_Phase2TrackerDTC_TrackerDetToDTCELinkCablingMap_h diff --git a/CondFormats/SiPhase2TrackerObjects/src/DTCELinkId.cc b/CondFormats/SiPhase2TrackerObjects/src/DTCELinkId.cc new file mode 100644 index 0000000000000..d32324233fc58 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/DTCELinkId.cc @@ -0,0 +1,50 @@ +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" + +#include +#include +#include + +DTCELinkId::DTCELinkId() noexcept : + elink_id_ (std::numeric_limits< decltype( elink_id() ) >::max()), + gbtlink_id_(std::numeric_limits< decltype( gbtlink_id() ) >::max()), + dtc_id_ (std::numeric_limits< decltype( dtc_id() ) >::max()) +{ + +} + +DTCELinkId::DTCELinkId(DTCELinkId const& rhs) noexcept : + elink_id_ (rhs.elink_id_ ), + gbtlink_id_(rhs.gbtlink_id_), + dtc_id_ (rhs.dtc_id_ ) {} + +DTCELinkId::DTCELinkId(DTCELinkId&& rhs) noexcept : + elink_id_ (rhs.elink_id_ ), + gbtlink_id_(rhs.gbtlink_id_), + dtc_id_ (rhs.dtc_id_ ) {} + +DTCELinkId& DTCELinkId::operator=(DTCELinkId const& rhs) noexcept +{ + elink_id_ = rhs.elink_id_ ; + gbtlink_id_ = rhs.gbtlink_id_; + dtc_id_ = rhs.dtc_id_ ; + + return *this; +} + +DTCELinkId& DTCELinkId::operator=(DTCELinkId&& rhs) noexcept +{ + elink_id_ = rhs.elink_id_ ; + gbtlink_id_ = rhs.gbtlink_id_; + dtc_id_ = rhs.dtc_id_ ; + + return *this; +} + +DTCELinkId::~DTCELinkId() noexcept {} + +DTCELinkId::DTCELinkId(uint16_t dtc_id, uint8_t gbtlink_id, uint8_t elink_id) noexcept : + elink_id_ (elink_id ), + gbtlink_id_(gbtlink_id), + dtc_id_ (dtc_id ) +{ +} diff --git a/CondFormats/SiPhase2TrackerObjects/src/T_EventSetup_TrackerDetToDTCELinkCablingMap.cc b/CondFormats/SiPhase2TrackerObjects/src/T_EventSetup_TrackerDetToDTCELinkCablingMap.cc new file mode 100644 index 0000000000000..2024a4099b453 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/T_EventSetup_TrackerDetToDTCELinkCablingMap.cc @@ -0,0 +1,4 @@ +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(TrackerDetToDTCELinkCablingMap); diff --git a/CondFormats/SiPhase2TrackerObjects/src/TrackerDetToDTCELinkCablingMap.cc b/CondFormats/SiPhase2TrackerObjects/src/TrackerDetToDTCELinkCablingMap.cc new file mode 100644 index 0000000000000..c0181a6aa5652 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/TrackerDetToDTCELinkCablingMap.cc @@ -0,0 +1,103 @@ +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "FWCore/Utilities/interface/Exception.h" + +#include +#include +#include + +TrackerDetToDTCELinkCablingMap::TrackerDetToDTCELinkCablingMap() +{ + +} + +TrackerDetToDTCELinkCablingMap::~TrackerDetToDTCELinkCablingMap() +{ + +} + + +std::unordered_map::const_iterator TrackerDetToDTCELinkCablingMap::dtcELinkIdToDetId(DTCELinkId const& key) const +{ + if (cablingMapDTCELinkIdToDetId_.find(key) == cablingMapDTCELinkIdToDetId_.end()) + { + throw cms::Exception("TrackerDetToDTCELinkCablingMap has been asked to return a DetId associated to a DTCELinkId, but the latter is unknown to the map. ")<<" (DTC, GBT, Elink) numbers = (" << key.dtc_id() << "," << key.gbtlink_id() << "," << key.elink_id() << ")" << std::endl; + } + + return cablingMapDTCELinkIdToDetId_.find(key); +} + + +std::pair::const_iterator, std::unordered_multimap::const_iterator> TrackerDetToDTCELinkCablingMap::detIdToDTCELinkId(uint32_t const key) const +{ + auto const DTCELinkId_itpair = cablingMapDetIdToDTCELinkId_.equal_range(key); + + if (DTCELinkId_itpair.first == cablingMapDetIdToDTCELinkId_.end()) + { + throw cms::Exception("TrackerDetToDTCELinkCablingMap has been asked to return a DTCELinkId associated to a DetId, but the latter is unknown to the map. ")<<" DetId = " << key << std::endl; + } + + return DTCELinkId_itpair; +} + + +bool TrackerDetToDTCELinkCablingMap::knowsDTCELinkId(DTCELinkId const& key) const +{ + return cablingMapDTCELinkIdToDetId_.find(key) != cablingMapDTCELinkIdToDetId_.end(); +} + +bool TrackerDetToDTCELinkCablingMap::knowsDetId(uint32_t key) const +{ + return cablingMapDetIdToDTCELinkId_.find(key) != cablingMapDetIdToDTCELinkId_.end(); +} + + +std::vector TrackerDetToDTCELinkCablingMap::getKnownDTCELinkIds() const +{ + std::vector knownDTCELinkIds(cablingMapDTCELinkIdToDetId_.size()); + + // Unzip the map into a vector of DTCELinkId, discarding the DetIds + std::transform(cablingMapDTCELinkIdToDetId_.begin(), cablingMapDTCELinkIdToDetId_.end(), knownDTCELinkIds.begin(), [=](auto pair){return pair.first;}); + + return knownDTCELinkIds; +} + + +std::vector TrackerDetToDTCELinkCablingMap::getKnownDetIds() const +{ + std::vector knownDetId; + + // To get the list of unique DetIds we need to iterate over the various equal_ranges + // in the map associated to each unique key, and count them only once. + + for (auto allpairs_it = cablingMapDetIdToDTCELinkId_.begin(), allpairs_end = cablingMapDetIdToDTCELinkId_.end(); allpairs_it != allpairs_end; ) + { + // ***Store the first instance of the key*** + knownDetId.push_back(uint32_t(allpairs_it->first)); + + // *** Skip to the end of the equal range *** + // The following is just explicative, the bottom expression is equivalent + //auto const current_key = allpairs_it->first; + //auto const current_key_equal_range = cablingMapDetIdToDTCELinkId_.equal_range(current_key); + //auto const current_key_range_end = current_key_equal_range.second; + auto const current_key_range_end = cablingMapDetIdToDTCELinkId_.equal_range(allpairs_it->first).second; + + while (allpairs_it != current_key_range_end) + ++allpairs_it; + } + + return knownDetId; +} + + +void TrackerDetToDTCELinkCablingMap::insert(DTCELinkId const& dtcELinkId, uint32_t const detId) +{ + cablingMapDTCELinkIdToDetId_.insert(std::make_pair(DTCELinkId(dtcELinkId), uint32_t(detId))); + cablingMapDetIdToDTCELinkId_.insert(std::make_pair(uint32_t(detId), DTCELinkId(dtcELinkId))); +} + + +void TrackerDetToDTCELinkCablingMap::clear() +{ + cablingMapDTCELinkIdToDetId_.clear(); + cablingMapDetIdToDTCELinkId_.clear(); +} diff --git a/CondFormats/SiPhase2TrackerObjects/src/classes.h b/CondFormats/SiPhase2TrackerObjects/src/classes.h new file mode 100644 index 0000000000000..43fe07a2e41e7 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/classes.h @@ -0,0 +1,19 @@ +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" +#include "DataFormats/DetId/interface/DetId.h" + +namespace +{ + struct dictionary + { + TrackerDetToDTCELinkCablingMap cabmap; + + DTCELinkId dtcelinkid; + + std::unordered_map unorderedMapUIntToDTC; + std::unordered_multimap unorderedMapDTCToUInt; + + std::pair unorderedMapUIntToDTC_data = std::make_pair(0,DTCELinkId()); + std::pair unorderedMapDTCToUInt_data = std::make_pair(DTCELinkId(),0); + }; +} diff --git a/CondFormats/SiPhase2TrackerObjects/src/classes_def.xml b/CondFormats/SiPhase2TrackerObjects/src/classes_def.xml new file mode 100644 index 0000000000000..e50610b3ff1a5 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/classes_def.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CondFormats/SiPhase2TrackerObjects/src/headers.h b/CondFormats/SiPhase2TrackerObjects/src/headers.h new file mode 100644 index 0000000000000..e44c446f709e9 --- /dev/null +++ b/CondFormats/SiPhase2TrackerObjects/src/headers.h @@ -0,0 +1,2 @@ +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" diff --git a/CondTools/CTPPS/BuildFile.xml b/CondTools/CTPPS/BuildFile.xml index 606b514ecbc6c..e219cd905d12b 100644 --- a/CondTools/CTPPS/BuildFile.xml +++ b/CondTools/CTPPS/BuildFile.xml @@ -3,6 +3,8 @@ + + diff --git a/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc new file mode 100644 index 0000000000000..63df5295455cf --- /dev/null +++ b/CondTools/CTPPS/plugins/RetrieveCTPPSBeamParameters.cc @@ -0,0 +1,61 @@ +// -*- C++ -*- +// +// Class: RetrieveCTPPSBeamParameters +// +// Description: Test analyzer for reading CTPPS beam parameters condition data +// +// Simple analyzer that retrieves CTTPSBeamParameters record from a sql +// database file, as a test of offline conditions implementation. +// +// Original Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 17:35:07 GMT +// +//================================================================================== + +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +class RetrieveCTPPSBeamParameters : public edm::one::EDAnalyzer<> +{ + public: + explicit RetrieveCTPPSBeamParameters(const edm::ParameterSet&); + ~RetrieveCTPPSBeamParameters() override = default; + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + std::string label_; +}; + +//--------------------------------------------------------------------------------------- + +RetrieveCTPPSBeamParameters::RetrieveCTPPSBeamParameters(const edm::ParameterSet& iConfig) +{} + +void RetrieveCTPPSBeamParameters::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle pSetup; + iSetup.get().get(label_, pSetup); + + const CTPPSBeamParameters* pInfo = pSetup.product(); + + edm::LogInfo("CTPPSBeamParameters") << "\n" << *pInfo << "\n" ; +} + +DEFINE_FWK_MODULE(RetrieveCTPPSBeamParameters); + diff --git a/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc new file mode 100644 index 0000000000000..4341e6285639b --- /dev/null +++ b/CondTools/CTPPS/plugins/WriteCTPPSBeamParameters.cc @@ -0,0 +1,76 @@ +// -*- C++ -*- +// +// Class: WriteCTPPSBeamParameters +// +// Description: Test analyzer for CTPPS beam parameters condition data +// +// Simple analyzer that writes one CTTPSBeamParameters record into a sql +// database file, as a test of offline conditions implementation. +// Another analyzer is then used to retrieve these conditions. +// +// Original Author: Wagner De Paula Carvalho +// Created: Wed, 21 Nov 2018 17:35:07 GMT +// +//================================================================================== + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Event.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +class WriteCTPPSBeamParameters : public edm::one::EDAnalyzer<> +{ + public: + WriteCTPPSBeamParameters(const edm::ParameterSet&) {} + ~WriteCTPPSBeamParameters() override = default; + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; +}; + +//--------------------------------------------------------------------------------------- + +void WriteCTPPSBeamParameters::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + edm::ESHandle bp ; + iSetup.get().get(bp) ; + + // Pointer for the conditions data object + const CTPPSBeamParameters *p = bp.product() ; + + // Using "lumiid" as IOV + const edm::LuminosityBlock &iLBlock = iEvent.getLuminosityBlock() ; + edm::LuminosityBlockID lu(iLBlock.run(), iLBlock.id().luminosityBlock()) ; + cond::Time_t ilumi = (cond::Time_t)(lu.value()) ; + // cond::Time_t itime = (cond::Time_t)(iEvent.time().value()) ; // use this for timestamp + + edm::LogInfo("WriteCTPPSBeamParameters::analyze") << "cond::Time_t ilumi = " << ilumi + << " = " << boost::posix_time::to_iso_extended_string( cond::time::to_boost( ilumi ) ) << "\n" ; + + // Write to database or sqlite file + edm::Service poolDbService; + if( poolDbService.isAvailable() ) + poolDbService->writeOne( p, ilumi, "CTPPSBeamParametersRcd" ); + // poolDbService->writeOne( p, poolDbService->currentTime(), "CTPPSBeamParametersRcd" ); + else + throw std::runtime_error("PoolDBService required."); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(WriteCTPPSBeamParameters); + diff --git a/CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py b/CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py index effae1fc38feb..4e49adc4cc3d4 100644 --- a/CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py +++ b/CondTools/CTPPS/test/ppsTimingCalibrationAnalyzer_cfg.py @@ -20,7 +20,7 @@ # load calibrations from database process.load('CondCore.CondDB.CondDB_cfi') -process.CondDB.connect = 'sqlite_file:totemTiming_calibration.sqlite' # SQLite input +process.CondDB.connect = 'sqlite_file:ppsDiamondTiming_calibration.sqlite' # SQLite input process.PoolDBESSource = cms.ESSource('PoolDBESSource', process.CondDB, @@ -28,7 +28,7 @@ toGet = cms.VPSet( cms.PSet( record = cms.string('PPSTimingCalibrationRcd'), - tag = cms.string('TotemTimingCalibration') + tag = cms.string('PPSDiamondTimingCalibration') ) ) ) diff --git a/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py b/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py index 5a845ad5de6f0..8ba510be79a3d 100644 --- a/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py +++ b/CondTools/CTPPS/test/ppsTimingCalibrationWriter_cfg.py @@ -9,15 +9,16 @@ interval = cms.uint64(1) ) +from CondFormats.CTPPSReadoutObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum + # load calibrations from JSON file process.load('CondFormats.CTPPSReadoutObjects.ppsTimingCalibrationESSource_cfi') -process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoCTPPS/TotemRPLocal/data/timing_offsets_ufsd_2018.dec18.cal.json') +process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoCTPPS/TotemRPLocal/data/timing_calibration_diamond_2018_mar19.ex.json') +process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND # output service for database process.load('CondCore.CondDB.CondDB_cfi') -process.CondDB.connect = 'sqlite_file:totemTiming_calibration.sqlite' # SQLite output -#process.CondDB.connect = 'oracle://cmsprep/TimingCalibration' # Oracle output -#process.CondDB.connect = 'frontier://cmsfrontier.cern.ch:8000/FrontierPrep/TimingCalibration' # Frontier output +process.CondDB.connect = 'sqlite_file:ppsDiamondTiming_calibration.sqlite' # SQLite output process.PoolDBOutputService = cms.Service('PoolDBOutputService', process.CondDB, @@ -25,7 +26,7 @@ toPut = cms.VPSet( cms.PSet( record = cms.string('PPSTimingCalibrationRcd'), - tag = cms.string('TotemTimingCalibration'), + tag = cms.string('PPSDiamondTimingCalibration'), ) ) ) diff --git a/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py new file mode 100644 index 0000000000000..510ea1e3840bb --- /dev/null +++ b/CondTools/CTPPS/test/retrieve-ctpps-beam-parameters_cfg.py @@ -0,0 +1,42 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("retrieveCTPPSBeamParametersTest") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# input database (in this case the local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string("CTPPSBeamParameters_v1") + )), +) + +process.get = cms.EDAnalyzer("RetrieveCTPPSBeamParameters", + verbose = cms.untracked.bool(True) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(3), + lastValue = cms.uint64(3), + interval = cms.uint64(1) + #timetype = cms.string('timestamp'), + #firstValue = cms.uint64(6542600000000000000), + #lastValue = cms.uint64(6542700000000000000), + #interval = cms.uint64(100000000000000) + # timetype = cms.string('lumiid'), +) + +process.path = cms.Path(process.get) diff --git a/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py b/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py new file mode 100644 index 0000000000000..0702975bcda39 --- /dev/null +++ b/CondTools/CTPPS/test/write-ctpps-beam-parameters_cfg.py @@ -0,0 +1,41 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("writeCTPPSBeamParameters") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:CTPPSBeamParameters.db' + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + # timetype = cms.string('lumiid'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + # timetype = cms.untracked.string('runnumber'), + # timetype = cms.untracked.string('timestamp'), + timetype = cms.untracked.string('lumiid'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('CTPPSBeamParametersRcd'), + tag = cms.string('CTPPSBeamParameters_v1') + )) +) + +process.parameters_maker = cms.EDAnalyzer("WriteCTPPSBeamParameters", + record = cms.string('CTPPSBeamParametersRcd'), + loggingOn= cms.untracked.bool(True), + SinceAppendMode=cms.bool(True), + Source=cms.PSet( + IOVRun=cms.untracked.uint32(1) + ) +) + +process.path = cms.Path(process.parameters_maker) diff --git a/CondTools/SiPhase2Tracker/BuildFile.xml b/CondTools/SiPhase2Tracker/BuildFile.xml new file mode 100644 index 0000000000000..5bfc8514af91d --- /dev/null +++ b/CondTools/SiPhase2Tracker/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CondTools/SiPhase2Tracker/plugins/BuildFile.xml b/CondTools/SiPhase2Tracker/plugins/BuildFile.xml new file mode 100644 index 0000000000000..f12023cd1934f --- /dev/null +++ b/CondTools/SiPhase2Tracker/plugins/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc new file mode 100644 index 0000000000000..01626758f70eb --- /dev/null +++ b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc @@ -0,0 +1,313 @@ +// -*- C++ -*- +// +// Package: CondTools/SiPhase2Tracker +// Class: DTCCablingMapProducer +// +/**\class DTCCablingMapProducer DTCCablingMapProducer.cc CondTools/SiPhase2Tracker/plugins/DTCCablingMapProducer.cc + +Description: [one line class summary] + +Implementation: + [Notes on implementation] +*/ +// +// Original Author: Luigi Calligaris, SPRACE, São Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// +// + +#include +#include +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +// #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/Common/interface/Time.h" +#include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" + + +// +// CONSTANTS +// + +static constexpr const unsigned int gbt_id_minvalue = 0; +static constexpr const unsigned int gbt_id_maxvalue = 72; +static constexpr const unsigned int elink_id_minvalue = 0; +static constexpr const unsigned int elink_id_maxvalue = 7; + + +// +// SOME HELPER FUNCTIONS +// + + + + +// trim from start (in place) +static inline void ltrim(std::string &s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) + { + return !std::isspace(ch); + })); +} + +// trim from end (in place) +static inline void rtrim(std::string &s) +{ + s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) + { + return !std::isspace(ch); + }).base(), s.end()); +} + +// trim from both ends (in place) +static inline void trim(std::string &s) +{ + ltrim(s); + rtrim(s); +} + + + +class DTCCablingMapProducer : public edm::one::EDAnalyzer<> +{ + public: + explicit DTCCablingMapProducer(const edm::ParameterSet&); + ~DTCCablingMapProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + virtual void LoadModulesToDTCCablingMapFromCSV(std::vector const&); + + private: + bool generate_fake_valid_gbtlink_and_elinkid_; + int verbosity_ ; + unsigned csvFormat_ncolumns_ ; + unsigned csvFormat_idetid_ ; + unsigned csvFormat_idtcid_ ; + unsigned csvFormat_igbtlinkid_ ; + unsigned csvFormat_ielinkid_ ; + cond::Time_t iovBeginTime_ ; + std::unique_ptr pCablingMap_ ; + std::string record_ ; +}; + + +void DTCCablingMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + desc.setComment("Stores a TrackerDetToDTCELinkCablingMap object into the database from a CSV file."); + desc.add("generate_fake_valid_gbtlink_and_elinkid", false); + desc.add("verbosity", 0); + desc.add("csvFormat_idetid" , 0); + desc.add("csvFormat_ncolumns" , 15); + desc.add("csvFormat_idtcid" , 10); + desc.add("csvFormat_igbtlinkid" , 11); + desc.add("csvFormat_ielinkid" , 12); + desc.add("iovBeginTime" , 1); + desc.add("record","TrackerDTCCablingMapRcd"); + desc.add>("modulesToDTCCablingCSVFileNames",std::vector()); + descriptions.add("DTCCablingMapProducer", desc); +} + +DTCCablingMapProducer::DTCCablingMapProducer(const edm::ParameterSet& iConfig): + generate_fake_valid_gbtlink_and_elinkid_ (iConfig.getParameter("generate_fake_valid_gbtlink_and_elinkid")), + verbosity_ (iConfig.getParameter("verbosity")), + csvFormat_ncolumns_ (iConfig.getParameter("csvFormat_ncolumns")), + csvFormat_idetid_ (iConfig.getParameter("csvFormat_idetid" )), + csvFormat_idtcid_ (iConfig.getParameter("csvFormat_idtcid" )), + iovBeginTime_ (iConfig.getParameter("iovBeginTime")), + pCablingMap_ (std::make_unique()), + record_ (iConfig.getParameter("record")) +{ + LoadModulesToDTCCablingMapFromCSV(iConfig.getParameter>("modulesToDTCCablingCSVFileNames")); +} + +void DTCCablingMapProducer::beginJob() +{ + +} + +void DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV(std::vector const& modulesToDTCCablingCSVFileNames) +{ + using namespace std; + + for (std::string const& csvFileName : modulesToDTCCablingCSVFileNames) + { + edm::FileInPath csvFilePath(csvFileName); + + ifstream csvFile; + csvFile.open(csvFilePath.fullPath().c_str()); + + if (csvFile.is_open()) + { + string csvLine; + + unsigned lineNumber = 0; + + while (std::getline(csvFile, csvLine)) + { + if (verbosity_ >= 1) + { + edm::LogInfo("CSVParser") << "Reading CSV file line: " << ++lineNumber << ": \"" << csvLine << "\"" << endl; + } + + istringstream csvStream(csvLine); + vector csvColumn; + string csvElement; + + while (std::getline(csvStream, csvElement, ',')) + { + trim(csvElement); + csvColumn.push_back(csvElement); + } + + if (verbosity_ >= 2) + { + ostringstream splitted_line_info; + + splitted_line_info << "-- split line is: ["; + + for (string const& s : csvColumn) + splitted_line_info << "\"" << s << "\", "; + + splitted_line_info << "]" << endl; + + edm::LogInfo("CSVParser") << splitted_line_info.str(); + } + + if (csvColumn.size() == csvFormat_ncolumns_) + { + // Skip the legend lines + if (0 == csvColumn[0].compare(std::string("Module DetId/U"))) + { + if (verbosity_ >= 1) + { + edm::LogInfo("CSVParser") << "-- skipping legend line" << endl; + } + continue; + } + + uint32_t detIdRaw; + + try + { + detIdRaw = std::stoi( csvColumn[csvFormat_idetid_] ); + } + catch (std::exception e) + { + if (verbosity_ >= 0) + { + edm::LogError("CSVParser") << "-- malformed DetId string in CSV file: \"" << csvLine << "\"" << endl; + } + throw e; + } + + unsigned const dtc_id = strtoul(csvColumn[csvFormat_idtcid_].c_str(), nullptr, 10); + unsigned gbt_id; + unsigned elink_id; + + + if (generate_fake_valid_gbtlink_and_elinkid_) + { + for (gbt_id = gbt_id_minvalue; gbt_id < gbt_id_maxvalue + 1u; ++gbt_id) + { + for (elink_id = elink_id_minvalue; elink_id < elink_id_maxvalue + 1u; ++elink_id) + { + if ( !(pCablingMap_->knowsDTCELinkId( DTCELinkId(dtc_id, gbt_id, elink_id) )) ) + goto gbtlink_and_elinkid_generator_end; //break out of this double loop + } + } + gbtlink_and_elinkid_generator_end: + ((void)0); // This is a NOP, it's here just to have a valid (although dummy) instruction after the goto tag + } + else + { + gbt_id = strtoul(csvColumn[csvFormat_igbtlinkid_].c_str(), nullptr, 10); + elink_id = strtoul(csvColumn[csvFormat_ielinkid_ ].c_str(), nullptr, 10); + } + + + DTCELinkId dtcELinkId( dtc_id, gbt_id, elink_id ); + + if (verbosity_ >= 3) + { + edm::LogInfo("CSVParser") << "-- DetId = " << detIdRaw << " (dtc_id, gbt_id, elink_id) = (" << dtc_id << "," << gbt_id << "," << elink_id << ")" << endl; + } + + if (pCablingMap_->knowsDTCELinkId(dtcELinkId)) + { + ostringstream message; + message << "Reading CSV file: CRITICAL ERROR, duplicated dtcELinkId entry about (dtc_id, gbt_id, elink_id) = (" << dtc_id << "," << gbt_id << "," << elink_id << ")"; + + throw cms::Exception(message.str()); + } + + pCablingMap_->insert(dtcELinkId, detIdRaw); + } + else + { + if (verbosity_ >= 3) + { + edm::LogInfo("CSVParser") << "Reading CSV file: Skipped a short line: \"" << csvLine << "\"" << endl; + } + } + } + } + else + { + throw cms::Exception("DTCCablingMapProducer: Unable to open input CSV file") << csvFilePath << endl; + } + + csvFile.close(); + } +} + +void DTCCablingMapProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + +} + +void DTCCablingMapProducer::endJob() +{ +// using namespace edm; + using namespace std; + + edm::Service poolDbService; + + if( poolDbService.isAvailable() ) + { + poolDbService->writeOne( pCablingMap_.release(), iovBeginTime_, record_ ); + } + else + { + throw cms::Exception("PoolDBService required."); + } +} + +DTCCablingMapProducer::~DTCCablingMapProducer() +{ + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(DTCCablingMapProducer); diff --git a/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestProducer.cc b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestProducer.cc new file mode 100644 index 0000000000000..a831a206128c9 --- /dev/null +++ b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestProducer.cc @@ -0,0 +1,109 @@ +// -*- C++ -*- +// +// Package: CondTools/SiPhase2Tracker +// Class: DTCCablingMapTestProducer +// +/**\class DTCCablingMapTestProducer DTCCablingMapTestProducer.cc CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestProducer.cc + +Description: [one line class summary] + +Implementation: + [Notes on implementation] +*/ +// +// Original Author: Luigi Calligaris, SPRACE, São Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// +// + +#include + +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/Common/interface/Time.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" +#include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h" + + +class DTCCablingMapTestProducer : public edm::one::EDAnalyzer<> +{ + public: + explicit DTCCablingMapTestProducer(const edm::ParameterSet&); + ~DTCCablingMapTestProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; +private: + cond::Time_t iovBeginTime_; + std::unique_ptr pCablingMap_ ; + std::string recordName_ ; +}; + +void DTCCablingMapTestProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + desc.setComment("Stores a dummy TrackerDetToDTCELinkCablingMap database object from a CSV file."); + desc.add("iovBeginTime", 1); + desc.add("record","TrackerDetToDTCELinkCablingMap"); + descriptions.add("DTCCablingMapTestProducer", desc); +} + +DTCCablingMapTestProducer::DTCCablingMapTestProducer(const edm::ParameterSet& iConfig): + iovBeginTime_(iConfig.getParameter("iovBeginTime")), + pCablingMap_ (std::make_unique()), + recordName_ (iConfig.getParameter("record")) +{ + +} + +void DTCCablingMapTestProducer::beginJob() +{ + using namespace edm; + using namespace std; + + pCablingMap_->insert(DTCELinkId(101u,1u,2u), 11111111); + pCablingMap_->insert(DTCELinkId(102u,2u,2u), 22222222); + pCablingMap_->insert(DTCELinkId(103u,3u,3u), 33333333); + pCablingMap_->insert(DTCELinkId(104u,4u,4u), 44444444); + + edm::Service poolDbService; + + if( poolDbService.isAvailable() ) + poolDbService->writeOne( pCablingMap_.release(), iovBeginTime_, recordName_ ); + else + throw std::runtime_error("PoolDBService required."); +} + + +void DTCCablingMapTestProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + +} + +void DTCCablingMapTestProducer::endJob() +{ + +} + +DTCCablingMapTestProducer::~DTCCablingMapTestProducer() +{ + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(DTCCablingMapTestProducer); diff --git a/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestReader.cc b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestReader.cc new file mode 100644 index 0000000000000..fa0973807e1b5 --- /dev/null +++ b/CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestReader.cc @@ -0,0 +1,147 @@ +// -*- C++ -*- +// +// Package: CondTools/SiPhase2Tracker +// Class: DTCCablingMapTestReader +// +/**\class DTCCablingMapTestReader DTCCablingMapTestReader.cc CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestReader.cc + +Description: [one line class summary] + +Implementation: + [Notes on implementation] +*/ +// +// Original Author: Luigi Calligaris, SPRACE, São Paulo, BR +// Created : Wed, 27 Feb 2019 21:41:13 GMT +// +// + +#include +#include +#include + +#include +#include + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h" +#include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h" +#include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h" + + +class DTCCablingMapTestReader : public edm::one::EDAnalyzer<> +{ + public: + explicit DTCCablingMapTestReader(const edm::ParameterSet&); + ~DTCCablingMapTestReader() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + +}; + + +void DTCCablingMapTestReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.add("DTCCablingMapTestReader", desc); +} + + +DTCCablingMapTestReader::DTCCablingMapTestReader(const edm::ParameterSet& iConfig) +{ + +} + + +DTCCablingMapTestReader::~DTCCablingMapTestReader() +{ + +} + + +void DTCCablingMapTestReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + using namespace std; + + edm::ESHandle cablingMapHandle; + iSetup.get().get( cablingMapHandle ); + TrackerDetToDTCELinkCablingMap const* p_cablingMap = cablingMapHandle.product(); + + { + ostringstream dump_DetToElink; + + dump_DetToElink << "Det To DTC ELink map elements dump (Python-style):" << endl; + std::vector const knownDetIds = p_cablingMap->getKnownDetIds(); + + dump_DetToElink << "{"; + for (uint32_t detId : knownDetIds) + { + + dump_DetToElink << "(" << detId << " : ["; + auto equal_range = p_cablingMap->detIdToDTCELinkId(detId); + + for (auto it = equal_range.first; it != equal_range.second; ++it) + dump_DetToElink << "(" << unsigned(it->second.dtc_id()) << ", " << unsigned(it->second.gbtlink_id()) << ", " << unsigned(it->second.elink_id()) << "), "; + + dump_DetToElink << "], "; + } + dump_DetToElink << "}" << endl; + + edm::LogInfo("DetToElinkCablingMapDump") << dump_DetToElink.str(); + } + + { + ostringstream dump_ElinkToDet; + + dump_ElinkToDet << "DTC Elink To Det map elements dump (Python-style):" << endl; + std::vector const knownDTCELinkIds = p_cablingMap->getKnownDTCELinkIds(); + + dump_ElinkToDet << "{"; + for (DTCELinkId const& currentELink : knownDTCELinkIds) + { + dump_ElinkToDet << "(" << unsigned(currentELink.dtc_id()) << ", " << unsigned(currentELink.gbtlink_id()) << ", " << unsigned(currentELink.elink_id()) << ") " << " : "; + auto detId_it = p_cablingMap->dtcELinkIdToDetId(currentELink); + + dump_ElinkToDet << detId_it->second << ", "; + } + dump_ElinkToDet << "}" << endl; + + edm::LogInfo("DetToElinkCablingMapDump") << dump_ElinkToDet.str(); + } +} + + +void DTCCablingMapTestReader::beginJob() +{ + +} + + +void DTCCablingMapTestReader::endJob() +{ + +} + +//define this as a plug-in +DEFINE_FWK_MODULE(DTCCablingMapTestReader); diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_dump.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_dump.py new file mode 100644 index 0000000000000..479a7ee61f563 --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_dump.py @@ -0,0 +1,44 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapPayloadDumpTest") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring( + 'cerr', + 'cout' + ), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ), +) + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# input database (in this case the local sqlite files) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap.db' + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + tag = cms.string("DTCCablingMapProducerUserRun") + )), +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +process.otdtccablingmap_producer = cms.EDAnalyzer("DTCCablingMapTestReader",) + +process.path = cms.Path(process.otdtccablingmap_producer) diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_retrieve.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_retrieve.py new file mode 100644 index 0000000000000..8d5db33c59104 --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_retrieve.py @@ -0,0 +1,36 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapPayloadRetrieveTest") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") + +process.load("CondCore.CondDB.CondDB_cfi") +# input database (in this case the local sqlite file) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap.db' + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + tag = cms.string("DTCCablingMapProducerUserRun") + )), +) + +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + data = cms.vstring('TrackerDetToDTCELinkCablingMap') + )), + verbose = cms.untracked.bool(True) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +process.path = cms.Path(process.get) diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_write.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_write.py new file mode 100644 index 0000000000000..070432ac8a435 --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapProducer_write.py @@ -0,0 +1,48 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapProducer") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap.db' + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + tag = cms.string('DTCCablingMapProducerUserRun') + )) +) + +process.otdtccablingmap_producer = cms.EDAnalyzer("DTCCablingMapProducer", + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + generate_fake_valid_gbtlink_and_elinkid = cms.bool(True), + modulesToDTCCablingCSVFileNames = cms.vstring( + "CondTools/SiPhase2Tracker/data/TrackerModuleToDTCCablingMap__OT616_200_IT613__T14__OTOnly.csv" + ), + csvFormat_ncolumns = cms.uint32( 2), + csvFormat_idetid = cms.uint32( 0), + csvFormat_idtcid = cms.uint32( 1), + verbosity = cms.int32(0), + #loggingOn= cms.untracked.bool(True), + #SinceAppendMode=cms.bool(True), + #Source=cms.PSet( + #IOVRun=cms.untracked.uint32(1) + #) +) + +process.path = cms.Path(process.otdtccablingmap_producer) diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_dump.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_dump.py new file mode 100644 index 0000000000000..ab40259d05ac9 --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_dump.py @@ -0,0 +1,54 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapPayloadDumpTest") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger = cms.Service("MessageLogger", + destinations = cms.untracked.vstring( + 'cerr', + 'cout' + ), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO') + ), +) + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# input database (in this case the local sqlite files) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap_dummytest.db' + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + tag = cms.string("DTCCablingMapProducerUserRun") + )), +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +## We define the output service. +#process.PoolDBOutputService = cms.Service("PoolDBOutputService", + #process.CondDB, + #timetype = cms.untracked.string('runnumber'), + #toPut = cms.VPSet(cms.PSet( + #record = cms.string('OuterTrackerDTCCablingMapRcd'), + #tag = cms.string('DTCCablingMapProducer_test') + #)) +#) + +process.otdtccablingmap_producer = cms.EDAnalyzer("DTCCablingMapTestReader",) + +process.path = cms.Path(process.otdtccablingmap_producer) diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_retrieve.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_retrieve.py new file mode 100644 index 0000000000000..7cb06123e0d76 --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_retrieve.py @@ -0,0 +1,36 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapPayloadRetrieveTest") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") + +process.load("CondCore.CondDB.CondDB_cfi") +# input database (in this case the local sqlite file) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap_dummytest.db' + +process.PoolDBESSource = cms.ESSource("PoolDBESSource", + process.CondDB, + DumpStat=cms.untracked.bool(True), + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + tag = cms.string("DTCCablingMapProducerUserRun") + )), +) + +process.get = cms.EDAnalyzer("EventSetupRecordDataGetter", + toGet = cms.VPSet(cms.PSet( + record = cms.string('TrackerDetToDTCELinkCablingMapRcd'), + data = cms.vstring('TrackerDetToDTCELinkCablingMap') + )), + verbose = cms.untracked.bool(True) +) + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +process.path = cms.Path(process.get) diff --git a/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_write.py b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_write.py new file mode 100644 index 0000000000000..6355ceeca53da --- /dev/null +++ b/CondTools/SiPhase2Tracker/test/DTCCablingMapTestProducer_write.py @@ -0,0 +1,40 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DTCCablingMapProducer") + +process.load("FWCore.MessageLogger.MessageLogger_cfi") + +# Load CondDB service +process.load("CondCore.CondDB.CondDB_cfi") + +# output database (in this case local sqlite file) +process.CondDB.connect = 'sqlite_file:OuterTrackerDTCCablingMap_dummytest.db' + +# A data source must always be defined. We don't need it, so here's a dummy one. +process.source = cms.Source("EmptyIOVSource", + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# We define the output service. +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet(cms.PSet( + record = cms.string('OuterTrackerDTCCablingMapRcd'), + tag = cms.string('DTCCablingMapProducerUserRun') + )) +) + +process.otdtccablingmap_producer = cms.EDAnalyzer("DTCCablingMapTestProducer", + record = cms.string('OuterTrackerDTCCablingMapRcd'), + #loggingOn= cms.untracked.bool(True), + #SinceAppendMode=cms.bool(True), + #Source=cms.PSet( + #IOVRun=cms.untracked.uint32(1) + #) +) + +process.path = cms.Path(process.otdtccablingmap_producer) diff --git a/Configuration/AlCa/python/autoCond.py b/Configuration/AlCa/python/autoCond.py index 37da2b1479bd3..b9be61d1aff8e 100644 --- a/Configuration/AlCa/python/autoCond.py +++ b/Configuration/AlCa/python/autoCond.py @@ -44,29 +44,29 @@ # GlobalTag for Run2 HLT for HI (not 2018 HI): it points to the online GT 'run2_hlt_hi' : '101X_dataRun2_HLTHI_frozen_v8', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017 (and 0,0,~0-centred beamspot) - 'phase1_2017_design' : '105X_mc2017_design_IdealBS_v6', + 'phase1_2017_design' : '106X_mc2017_design_IdealBS_v1', # GlobalTag for MC production with realistic conditions for Phase1 2017 detector - 'phase1_2017_realistic' : '105X_mc2017_realistic_v7', + 'phase1_2017_realistic' : '106X_mc2017_realistic_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in DECO mode - 'phase1_2017_cosmics' : '105X_mc2017cosmics_realistic_deco_v8', + 'phase1_2017_cosmics' : '106X_mc2017cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic alignment and calibrations for Phase1 2017 detector, Strip tracker in PEAK mode - 'phase1_2017_cosmics_peak' : '105X_mc2017cosmics_realistic_peak_v8', + 'phase1_2017_cosmics_peak' : '106X_mc2017cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for full Phase1 2018 (and 0,0,0-centred beamspot) - 'phase1_2018_design' : '105X_upgrade2018_design_v5', + 'phase1_2018_design' : '106X_upgrade2018_design_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector - 'phase1_2018_realistic' : '105X_upgrade2018_realistic_v6', + 'phase1_2018_realistic' : '106X_upgrade2018_realistic_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector for Heavy Ion - 'phase1_2018_realistic_hi' : '105X_upgrade2018_realistic_HI_v4', + 'phase1_2018_realistic_hi' : '106X_upgrade2018_realistic_HI_v1', # GlobalTag for MC production with realistic conditions for full Phase1 2018 detector: HEM-15-16 fail - 'phase1_2018_realistic_HEfail' : '105X_upgrade2018_realistic_HEfail_v6', + 'phase1_2018_realistic_HEfail' : '106X_upgrade2018_realistic_HEfail_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in DECO mode - 'phase1_2018_cosmics' : '105X_upgrade2018cosmics_realistic_deco_v7', + 'phase1_2018_cosmics' : '106X_upgrade2018cosmics_realistic_deco_v1', # GlobalTag for MC production (cosmics) with realistic conditions for full Phase1 2018 detector, Strip tracker in PEAK mode - 'phase1_2018_cosmics_peak' : '105X_upgrade2018cosmics_realistic_peak_v7', + 'phase1_2018_cosmics_peak' : '106X_upgrade2018cosmics_realistic_peak_v1', # GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019 - 'phase1_2019_design' : '105X_postLS2_design_v4', # GT containing design conditions for postLS2 + 'phase1_2019_design' : '106X_postLS2_design_v1', # GT containing design conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase1 2019 - 'phase1_2019_realistic' : '105X_postLS2_realistic_v6', # GT containing realistic conditions for postLS2 + 'phase1_2019_realistic' : '106X_postLS2_realistic_v1', # GT containing realistic conditions for postLS2 # GlobalTag for MC production with realistic conditions for Phase2 2023 'phase2_realistic' : '105X_upgrade2023_realistic_v5' } diff --git a/Configuration/DataProcessing/python/Merge.py b/Configuration/DataProcessing/python/Merge.py index e7a881e72c4ca..915886f804535 100644 --- a/Configuration/DataProcessing/python/Merge.py +++ b/Configuration/DataProcessing/python/Merge.py @@ -28,7 +28,7 @@ def mergeProcess(*inputFiles, **options): - output_file : sets the output file name - output_lfn : sets the output LFN - mergeNANO : to merge NanoAOD - - bypassVersionCheck : to bypass version check in case merging happened in lower version of CMSSW (i.e. UL HLT case). This will be TRUE by default. + - bypassVersionCheck : to bypass version check in case merging happened in lower version of CMSSW (i.e. UL HLT case). This will be FALSE by default. """ # // @@ -41,7 +41,7 @@ def mergeProcess(*inputFiles, **options): dropDQM = options.get("drop_dqm", False) newDQMIO = options.get("newDQMIO", False) mergeNANO = options.get("mergeNANO", False) - bypassVersionCheck = options.get("bypassVersionCheck", True) + bypassVersionCheck = options.get("bypassVersionCheck", False) # // # // build process #// @@ -55,7 +55,8 @@ def mergeProcess(*inputFiles, **options): process.add_(Service("DQMStore")) else: process.source = Source("PoolSource") - process.source.bypassVersionCheck = CfgTypes.untracked.bool(bypassVersionCheck) + if bypassVersionCheck: + process.source.bypassVersionCheck = CfgTypes.untracked.bool(True) if dropDQM: process.source.inputCommands = CfgTypes.untracked.vstring('keep *','drop *_EDMtoMEConverter_*_*') process.source.fileNames = CfgTypes.untracked(CfgTypes.vstring()) diff --git a/Configuration/DataProcessing/test/RunMerge.py b/Configuration/DataProcessing/test/RunMerge.py index b99d0a090a1f5..a8fca59b84bc0 100644 --- a/Configuration/DataProcessing/test/RunMerge.py +++ b/Configuration/DataProcessing/test/RunMerge.py @@ -24,7 +24,7 @@ def __init__(self): self.inputFiles = [] self.newDQMIO = False self.mergeNANO = False - self.bypassVersionCheck = True + self.bypassVersionCheck = False def __call__(self): diff --git a/Configuration/Eras/python/Era_Phase2_cff.py b/Configuration/Eras/python/Era_Phase2_cff.py index 46514e1042f1e..6969b27acdcbe 100644 --- a/Configuration/Eras/python/Era_Phase2_cff.py +++ b/Configuration/Eras/python/Era_Phase2_cff.py @@ -10,5 +10,7 @@ from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 +from Configuration.Eras.Modifier_hcalHardcodeConditions_cff import hcalHardcodeConditions -Phase2 = cms.ModifierChain(Run3.copyAndExclude([phase1Pixel,trackingPhase1]), phase2_common, phase2_tracker, trackingPhase2PU140, phase2_ecal, phase2_hcal, phase2_hgcal, phase2_muon) + +Phase2 = cms.ModifierChain(Run3.copyAndExclude([phase1Pixel,trackingPhase1]), phase2_common, phase2_tracker, trackingPhase2PU140, phase2_ecal, phase2_hcal, phase2_hgcal, phase2_muon, hcalHardcodeConditions) diff --git a/Configuration/Eras/python/Era_Run3_cff.py b/Configuration/Eras/python/Era_Run3_cff.py index 887a8626e6f97..fc2b7ef96d3a1 100644 --- a/Configuration/Eras/python/Era_Run3_cff.py +++ b/Configuration/Eras/python/Era_Run3_cff.py @@ -5,7 +5,6 @@ from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM from Configuration.Eras.Modifier_run3_HB_cff import run3_HB from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 -from Configuration.Eras.Modifier_hcalHardcodeConditions_cff import hcalHardcodeConditions -Run3 = cms.ModifierChain(Run2_2018.copyAndExclude([run2_GEM_2017]), run3_common, run3_GEM, run3_HB, hcalHardcodeConditions) +Run3 = cms.ModifierChain(Run2_2018.copyAndExclude([run2_GEM_2017]), run3_common, run3_GEM, run3_HB) diff --git a/Configuration/Geometry/README.md b/Configuration/Geometry/README.md index 537d9d3a87d6d..c68c82ec5619f 100644 --- a/Configuration/Geometry/README.md +++ b/Configuration/Geometry/README.md @@ -16,9 +16,11 @@ Calorimeters: * C5: HGCal (v9 without virtual wafers) + Phase2 HCAL and EB * C6: HGCal (v9) + HFNose + Phase2 HCAL and EB * C7: HGCal (v9a with inner support structure) + Phase2 HCAL and EB +* C8: HGCal (v10 post TDR HGCal Geometry) + Phase2 HCAL and EB + Tracker cables in calorimeter region Muon system: * M2: Phase2 muon system for TDR w/ GE2/1, ME0, RE3/1, RE4/1 (incl. granularity in ME0, staggered GE2/1) +* M3: same as M2 with change to the number of iRPC strips from 192 to 96 as in TDR Fast Timing system: * I1: No Fast Timing detector @@ -29,9 +31,11 @@ Fast Timing system: * I6: Fast Timing detector (LYSO barrel, silicon endcap), full description with passive materials, LYSO bars along z flat no hole between modules * I7: Fast Timing detector (LYSO barrel, silicon endcap), full description with passive materials, LYSO bars along phi flat * I8: Fast Timing detector (LYSO barrel, silicon endcap), full description with passive materials, LYSO bars along phi flat, crystal thickness as I5 +* I9: Same as I7 but with ETL in the position defined in O3 The script also handles the common and forward elements of the geometry: * O2: detailed cavern description +* O3: O2 + changes due to modified CALO region due to changes in the Endcap part * F2: modifications needed to accommodate detailed cavern, ZDC description is removed. * F3: same as F2 but changes due to HFNose @@ -54,5 +58,6 @@ Several detector combinations have been generated: * D38 = T6+C4+M2+I7+O2+F2 * D39 = T6+C4+M2+I8+O2+F2 * D40 = T14+C3+M2+I1+O2+F2 +* D41 = T14+C8+M3+I9+O3+F2 Currently, D17 is considered to be the baseline for the Phase 2 Muon and Barrel TDRs. diff --git a/Configuration/Geometry/python/GeometryExtended2023D41Reco_cff.py b/Configuration/Geometry/python/GeometryExtended2023D41Reco_cff.py new file mode 100644 index 0000000000000..bbd185b28fe67 --- /dev/null +++ b/Configuration/Geometry/python/GeometryExtended2023D41Reco_cff.py @@ -0,0 +1,60 @@ +import FWCore.ParameterSet.Config as cms + +# This config was generated automatically using generate2023Geometry.py +# If you notice a mistake, please update the generating script, not just this config + +from Configuration.Geometry.GeometryExtended2023D41_cff import * + +# tracker +from Geometry.CommonDetUnit.globalTrackingGeometry_cfi import * +from RecoTracker.GeometryESProducer.TrackerRecoGeometryESProducer_cfi import * +from Geometry.TrackerGeometryBuilder.trackerParameters_cfi import * +from Geometry.TrackerNumberingBuilder.trackerTopology_cfi import * +from Geometry.TrackerGeometryBuilder.idealForDigiTrackerGeometry_cff import * +trackerGeometry.applyAlignment = cms.bool(False) + +# calo +from Geometry.CaloEventSetup.HGCalV9Topology_cfi import * +from Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi import * +from Geometry.CaloEventSetup.CaloTopology_cfi import * +from Geometry.CaloEventSetup.CaloGeometryBuilder_cfi import * +CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder", + SelectedCalos = cms.vstring("HCAL", + "ZDC", + "EcalBarrel", + "TOWER", + "HGCalEESensitive", + "HGCalHESiliconSensitive", + "HGCalHEScintillatorSensitive" + ) +) +from Geometry.EcalAlgo.EcalBarrelGeometry_cfi import * +from Geometry.HcalEventSetup.HcalGeometry_cfi import * +from Geometry.HcalEventSetup.CaloTowerGeometry_cfi import * +from Geometry.HcalEventSetup.CaloTowerTopology_cfi import * +from Geometry.HcalCommonData.hcalDDDRecConstants_cfi import * +from Geometry.HcalEventSetup.hcalTopologyIdeal_cfi import * +from Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi import * +from Geometry.EcalMapping.EcalMapping_cfi import * +from Geometry.EcalMapping.EcalMappingRecord_cfi import * + +# muon +from Geometry.MuonNumbering.muonNumberingInitialization_cfi import * +from RecoMuon.DetLayers.muonDetLayerGeometry_cfi import * +from Geometry.GEMGeometryBuilder.gemGeometry_cfi import * +from Geometry.GEMGeometryBuilder.me0Geometry_cfi import * +from Geometry.CSCGeometryBuilder.idealForDigiCscGeometry_cff import * +from Geometry.DTGeometryBuilder.idealForDigiDtGeometry_cff import * + +# forward +from Geometry.ForwardGeometry.ForwardGeometry_cfi import * + +# timing +from RecoMTD.DetLayers.mtdDetLayerGeometry_cfi import * +from Geometry.MTDGeometryBuilder.mtdParameters_cfi import * +from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import * +from Geometry.MTDNumberingBuilder.mtdTopology_cfi import * +from Geometry.MTDGeometryBuilder.mtdGeometry_cfi import * +from Geometry.MTDGeometryBuilder.idealForDigiMTDGeometry_cff import * +mtdGeometry.applyAlignment = cms.bool(False) + diff --git a/Configuration/Geometry/python/GeometryExtended2023D41_cff.py b/Configuration/Geometry/python/GeometryExtended2023D41_cff.py new file mode 100644 index 0000000000000..2e87adc5f70b4 --- /dev/null +++ b/Configuration/Geometry/python/GeometryExtended2023D41_cff.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +# This config was generated automatically using generate2023Geometry.py +# If you notice a mistake, please update the generating script, not just this config + +from Geometry.CMSCommonData.cmsExtendedGeometry2023D41XML_cfi import * +from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import * +from SLHCUpgradeSimulations.Geometry.fakeConditions_phase2TkT14_cff import * +from Geometry.HcalCommonData.hcalParameters_cfi import * +from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import * +from Geometry.HGCalCommonData.hgcalParametersInitialization_cfi import * +from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import * +from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import * diff --git a/Configuration/Geometry/python/dict2023Geometry.py b/Configuration/Geometry/python/dict2023Geometry.py index ac48c7a4bb76a..557e8db872290 100644 --- a/Configuration/Geometry/python/dict2023Geometry.py +++ b/Configuration/Geometry/python/dict2023Geometry.py @@ -30,6 +30,34 @@ 'Geometry/CMSCommonData/data/FieldParameters.xml', ], "era" : "run2_common, run3_common, phase2_common", + }, + + "O3" : { + 1 : [ + 'Geometry/CMSCommonData/data/materials.xml', + 'Geometry/CMSCommonData/data/rotations.xml', + 'Geometry/CMSCommonData/data/extend/v2/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms/2023/v2/cms.xml', + 'Geometry/CMSCommonData/data/eta3/etaMax.xml', + 'Geometry/CMSCommonData/data/cmsMother.xml', + 'Geometry/CMSCommonData/data/cmsTracker.xml', + 'Geometry/CMSCommonData/data/caloBase/2023/v2/caloBase.xml', + 'Geometry/CMSCommonData/data/cmsCalo.xml', + 'Geometry/CMSCommonData/data/muonBase/2023/v2/muonBase.xml', + 'Geometry/CMSCommonData/data/cmsMuon.xml', + 'Geometry/CMSCommonData/data/mgnt.xml', + 'Geometry/CMSCommonData/data/beampipe/2023/v1/beampipe.xml', + 'Geometry/CMSCommonData/data/cmsBeam/2023/v1/cmsBeam.xml', + 'Geometry/CMSCommonData/data/muonMB.xml', + 'Geometry/CMSCommonData/data/muonMagnet.xml', + 'Geometry/CMSCommonData/data/cavern/2017/v2/cavern.xml', + 'Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml', + 'Geometry/CMSCommonData/data/cavernFloor/2017/v1/cavernFloor.xml', + ], + 5 : [ + 'Geometry/CMSCommonData/data/FieldParameters.xml', + ], + "era" : "run2_common, run3_common, phase2_common", } } @@ -636,6 +664,80 @@ "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", }, + "C8" : { + 1 : [ + 'Geometry/EcalCommonData/data/PhaseII/v2/eregalgo.xml', + 'Geometry/EcalCommonData/data/PhaseII/v2/ectkcable.xml', + 'Geometry/EcalCommonData/data/PhaseII/v2/ectkcablemat.xml', + 'Geometry/EcalCommonData/data/ebalgo.xml', + 'Geometry/EcalCommonData/data/ebcon.xml', + 'Geometry/EcalCommonData/data/ebrot.xml', + 'Geometry/HcalCommonData/data/hcalrotations.xml', + 'Geometry/HcalCommonData/data/hcal/v2/hcalalgo.xml', + 'Geometry/HcalCommonData/data/hcalbarrelalgo.xml', + 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', + 'Geometry/HcalCommonData/data/hcalouteralgo.xml', + 'Geometry/HcalCommonData/data/hcalforwardalgo.xml', + 'Geometry/HcalCommonData/data/hcalSimNumbering/NoHE/hcalSimNumbering.xml', + 'Geometry/HcalCommonData/data/hcalRecNumbering/NoHE/hcalRecNumbering.xml', + 'Geometry/HcalCommonData/data/average/hcalforwardmaterial.xml', + 'Geometry/HGCalCommonData/data/hgcalMaterial/v1/hgcalMaterial.xml', + 'Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml', + 'Geometry/HGCalCommonData/data/hgcalEE/v10/hgcalEE.xml', + 'Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml', + 'Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml', + 'Geometry/HGCalCommonData/data/hgcalwafer/v9/hgcalwafer.xml', + 'Geometry/HGCalCommonData/data/hgcalcell/v9/hgcalcell.xml', + 'Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml', + ], + 3 : [ + 'Geometry/EcalSimData/data/PhaseII/ecalsens.xml', + 'Geometry/HcalCommonData/data/hcalsens/NoHE/hcalsenspmf.xml', + 'Geometry/HcalSimData/data/hf.xml', + 'Geometry/HcalSimData/data/hfpmt.xml', + 'Geometry/HcalSimData/data/hffibrebundle.xml', + 'Geometry/HcalSimData/data/CaloUtil.xml', + 'Geometry/HGCalSimData/data/hgcsensv9.xml', + ], + 4 : [ + 'Geometry/HcalSimData/data/HcalProdCuts.xml', + 'Geometry/EcalSimData/data/EcalProdCuts.xml', + 'Geometry/HGCalSimData/data/hgcProdCutsv9.xml', + ], + "sim" : [ + 'from Geometry.HcalCommonData.hcalParameters_cfi import *', + 'from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import *', + 'from Geometry.HGCalCommonData.hgcalParametersInitialization_cfi import *', + 'from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import *' + ], + "reco" : [ + 'from Geometry.CaloEventSetup.HGCalV9Topology_cfi import *', + 'from Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi import *', + 'from Geometry.CaloEventSetup.CaloTopology_cfi import *', + 'from Geometry.CaloEventSetup.CaloGeometryBuilder_cfi import *', + 'CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder",', + ' SelectedCalos = cms.vstring("HCAL",', + ' "ZDC",', + ' "EcalBarrel",', + ' "TOWER",', + ' "HGCalEESensitive",', + ' "HGCalHESiliconSensitive",', + ' "HGCalHEScintillatorSensitive"', + ' )', + ')', + 'from Geometry.EcalAlgo.EcalBarrelGeometry_cfi import *', + 'from Geometry.HcalEventSetup.HcalGeometry_cfi import *', + 'from Geometry.HcalEventSetup.CaloTowerGeometry_cfi import *', + 'from Geometry.HcalEventSetup.CaloTowerTopology_cfi import *', + 'from Geometry.HcalCommonData.hcalDDDRecConstants_cfi import *', + 'from Geometry.HcalEventSetup.hcalTopologyIdeal_cfi import *', + 'from Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi import *', + 'from Geometry.EcalMapping.EcalMapping_cfi import *', + 'from Geometry.EcalMapping.EcalMappingRecord_cfi import *', + ], + "era" : "run2_HE_2017, run2_HF_2017, run2_HCAL_2017, run3_HB, phase2_hcal, phase2_hgcal, hcalHardcodeConditions, hcalSkipPacker", + }, + } muonDict = { @@ -683,7 +785,50 @@ 'from Geometry.DTGeometryBuilder.idealForDigiDtGeometry_cff import *', ], "era" : "phase2_muon, run3_GEM", - } + }, + + "M3" : { + 1 : [ + 'Geometry/MuonCommonData/data/mbCommon/2017/v2/mbCommon.xml', + 'Geometry/MuonCommonData/data/mb1/2015/v1/mb1.xml', + 'Geometry/MuonCommonData/data/mb2/2015/v1/mb2.xml', + 'Geometry/MuonCommonData/data/mb3/2015/v1/mb3.xml', + 'Geometry/MuonCommonData/data/mb4/2015/v1/mb4.xml', + 'Geometry/MuonCommonData/data/design/muonYoke.xml', + 'Geometry/MuonCommonData/data/mf/2023/v2/mf.xml', + 'Geometry/MuonCommonData/data/rpcf/2023/v1/rpcf.xml', + 'Geometry/MuonCommonData/data/gemf/TDR_BaseLine/gemf.xml', + 'Geometry/MuonCommonData/data/gem11/TDR_BaseLine/gem11.xml', + 'Geometry/MuonCommonData/data/gem21/TDR_Dev/gem21.xml', + 'Geometry/MuonCommonData/data/csc/2015/v1/csc.xml', + 'Geometry/MuonCommonData/data/mfshield/2023/v1/mfshield.xml', + 'Geometry/MuonCommonData/data/me0/TDR_Dev/me0.xml', + ], + 2 : [ + 'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml', + ], + 3 : [ + 'Geometry/MuonSimData/data/PhaseII/ME0EtaPart/muonSens.xml', + 'Geometry/DTGeometryBuilder/data/dtSpecsFilter.xml', + 'Geometry/CSCGeometryBuilder/data/cscSpecsFilter.xml', + 'Geometry/CSCGeometryBuilder/data/cscSpecs.xml', + 'Geometry/RPCGeometryBuilder/data/2023/v1/RPCSpecs.xml', + 'Geometry/GEMGeometryBuilder/data/v7/GEMSpecsFilter.xml', + 'Geometry/GEMGeometryBuilder/data/v7/GEMSpecs.xml', + ], + 4 : [ + 'Geometry/MuonSimData/data/PhaseII/muonProdCuts.xml', + ], + "reco" : [ + 'from Geometry.MuonNumbering.muonNumberingInitialization_cfi import *', + 'from RecoMuon.DetLayers.muonDetLayerGeometry_cfi import *', + 'from Geometry.GEMGeometryBuilder.gemGeometry_cfi import *', + 'from Geometry.GEMGeometryBuilder.me0Geometry_cfi import *', + 'from Geometry.CSCGeometryBuilder.idealForDigiCscGeometry_cff import *', + 'from Geometry.DTGeometryBuilder.idealForDigiDtGeometry_cff import *', + ], + "era" : "phase2_muon, run3_GEM", + }, } @@ -942,6 +1087,35 @@ ], "era" : "phase2_timing, phase2_timing_layer_bar", }, + + "I9" : { + 1 : [ + 'Geometry/MTDCommonData/data/btl.xml', + 'Geometry/MTDCommonData/data/etl/v2/etl.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/v2/mtd.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdStructureTopology.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml', + ], + 3 : [ + 'Geometry/MTDSimData/data/CrystalBarPhiFlat/mtdsens.xml' + ], + 4 : [ + 'Geometry/MTDSimData/data/CrystalBarPhiFlat/mtdProdCuts.xml' + ], + "sim" : [ + 'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *', + ], + "reco" :[ + 'from RecoMTD.DetLayers.mtdDetLayerGeometry_cfi import *', + 'from Geometry.MTDGeometryBuilder.mtdParameters_cfi import *', + 'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *', + 'from Geometry.MTDNumberingBuilder.mtdTopology_cfi import *', + 'from Geometry.MTDGeometryBuilder.mtdGeometry_cfi import *', + 'from Geometry.MTDGeometryBuilder.idealForDigiMTDGeometry_cff import *', + 'mtdGeometry.applyAlignment = cms.bool(False)' + ], + "era" : "phase2_timing, phase2_timing_layer_bar", + }, } allDicts = [ commonDict, trackerDict, caloDict, muonDict, forwardDict, timingDict ] @@ -965,6 +1139,7 @@ ("O2","T6","C4","M2","F2","I7") : "D38", ("O2","T6","C4","M2","F2","I8") : "D39", ("O2","T14","C3","M2","F2","I1") : "D40", + ("O3","T14","C8","M3","F2","I9") : "D41", } deprecatedDets = set([ "D1", "D2", "D3", "D5", "D6" , "D7", "D4", "D8" , "D9", "D12", "D13", "D15", "D10", "D11", "D14", "D16", "D18", "D20", "D22", "D23", "D26", "D27" ]) diff --git a/Configuration/ProcessModifiers/python/trackdnn_cff.py b/Configuration/ProcessModifiers/python/trackdnn_cff.py new file mode 100644 index 0000000000000..aa14e5d6711e4 --- /dev/null +++ b/Configuration/ProcessModifiers/python/trackdnn_cff.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier sets the used tracking classifier to be a deep neural network instead of the BDT +trackdnn = cms.Modifier() diff --git a/Configuration/PyReleaseValidation/python/MatrixInjector.py b/Configuration/PyReleaseValidation/python/MatrixInjector.py index 926be20262460..943b5cd35cade 100644 --- a/Configuration/PyReleaseValidation/python/MatrixInjector.py +++ b/Configuration/PyReleaseValidation/python/MatrixInjector.py @@ -256,6 +256,7 @@ def prepare(self,mReader, directories, mode='init'): wmsplit['HYBRIDRepackHI2015VR']=1 wmsplit['HYBRIDZSHI2015']=1 wmsplit['RECOHID15']=1 + wmsplit['RECOHID18']=1 #import pprint #pprint.pprint(wmsplit) diff --git a/Configuration/PyReleaseValidation/python/relval_2023.py b/Configuration/PyReleaseValidation/python/relval_2023.py index 17f08983250df..950e4b26f5d3d 100644 --- a/Configuration/PyReleaseValidation/python/relval_2023.py +++ b/Configuration/PyReleaseValidation/python/relval_2023.py @@ -25,5 +25,6 @@ numWFIB.extend([23634.0]) #2023D37 numWFIB.extend([27834.0]) #2023D38 numWFIB.extend([28634.0]) #2023D40 +numWFIB.extend([29034.0]) #2023D41 for numWF in numWFIB: workflows[numWF] = _upgrade_workflows[numWF] diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index b74222f392fa0..22193a75a6004 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2923,6 +2923,7 @@ def gen2018HiMix(fragment,howMuch): defaultDataSets['2023D38']='' defaultDataSets['2023D39']='' defaultDataSets['2023D40']='' +defaultDataSets['2023D41']='' keys=defaultDataSets.keys() for key in keys: @@ -3180,7 +3181,7 @@ def gen2018HiMix(fragment,howMuch): for step in upgradeSteps['ParkingBPH']['steps']: stepName = step + upgradeSteps['ParkingBPH']['suffix'] - if 'Reco' in step and upgradeStepDict[step][k]['--era']=='Run2_2018': + if 'Reco' in step and 'Run2_2018' in upgradeStepDict[step][k]['--era']: upgradeStepDict[stepName][k] = merge([{'--era': 'Run2_2018,bParking'}, upgradeStepDict[step][k]]) # setup PU diff --git a/Configuration/PyReleaseValidation/python/relval_upgrade.py b/Configuration/PyReleaseValidation/python/relval_upgrade.py index 6554343efcac3..149d55a2485de 100644 --- a/Configuration/PyReleaseValidation/python/relval_upgrade.py +++ b/Configuration/PyReleaseValidation/python/relval_upgrade.py @@ -15,7 +15,7 @@ def makeStepNameSim(key,frag,step,suffix): def makeStepName(key,frag,step,suffix): return step+suffix+'_'+key -neutronKeys = ['2023D17','2023D19','2023D21','2023D24','2023D25','2023D28','2023D29','2023D30','2023D31','2023D33','2023D34','2023D35','2023D36','2023D37','2023D38','2023D39','2023D40'] +neutronKeys = ['2023D17','2023D19','2023D21','2023D24','2023D25','2023D28','2023D29','2023D30','2023D31','2023D33','2023D34','2023D35','2023D36','2023D37','2023D38','2023D39','2023D40','2023D41'] neutronFrags = ['ZMM_14','MinBias_14TeV'] tbmFrags = ['TTbar_13','ZMM_13'] diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 4bdbb2130e311..4a9e80f350080 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -54,6 +54,8 @@ '2023D39PU', '2023D40', '2023D40PU', + '2023D41', + '2023D41PU', ] # pre-generation of WF numbers @@ -422,6 +424,13 @@ 'Era' : 'Phase2', 'ScenToRun' : ['GenSimHLBeamSpotFull','DigiFullTrigger','RecoFullGlobal', 'HARVESTFullGlobal'], }, + '2023D41' : { + 'Geom' : 'Extended2023D41', + 'HLTmenu': '@fake2', + 'GT' : 'auto:phase2_realistic', + 'Era' : 'Phase2C4_timing_layer_bar', + 'ScenToRun' : ['GenSimHLBeamSpotFull','DigiFullTrigger','RecoFullGlobal', 'HARVESTFullGlobal'], + }, } @@ -461,6 +470,8 @@ upgradeProperties[2023]['2023D39PU']['ScenToRun'] = ['GenSimHLBeamSpotFull','DigiFullTriggerPU','RecoFullGlobalPU', 'HARVESTFullGlobalPU'] upgradeProperties[2023]['2023D40PU'] = deepcopy(upgradeProperties[2023]['2023D40']) upgradeProperties[2023]['2023D40PU']['ScenToRun'] = ['GenSimHLBeamSpotFull','DigiFullTriggerPU','RecoFullGlobalPU', 'HARVESTFullGlobalPU'] +upgradeProperties[2023]['2023D41PU'] = deepcopy(upgradeProperties[2023]['2023D41']) +upgradeProperties[2023]['2023D41PU']['ScenToRun'] = ['GenSimHLBeamSpotFull','DigiFullTriggerPU','RecoFullGlobalPU', 'HARVESTFullGlobalPU'] from Configuration.PyReleaseValidation.relval_steps import Kby diff --git a/Configuration/StandardSequences/python/GeometryConf.py b/Configuration/StandardSequences/python/GeometryConf.py index 49285f9280a18..cfecde9dddf34 100644 --- a/Configuration/StandardSequences/python/GeometryConf.py +++ b/Configuration/StandardSequences/python/GeometryConf.py @@ -46,4 +46,5 @@ 'Extended2023D38' : 'Extended2023D38,Extended2023D38Reco', 'Extended2023D39' : 'Extended2023D39,Extended2023D39Reco', 'Extended2023D40' : 'Extended2023D40,Extended2023D40Reco', + 'Extended2023D41' : 'Extended2023D41,Extended2023D41Reco', } diff --git a/Configuration/StandardSequences/python/Reconstruction_cff.py b/Configuration/StandardSequences/python/Reconstruction_cff.py index 4d4edf170e296..13f475ceb8b7f 100644 --- a/Configuration/StandardSequences/python/Reconstruction_cff.py +++ b/Configuration/StandardSequences/python/Reconstruction_cff.py @@ -90,7 +90,8 @@ ########################################### _fastSim_localreco = localreco.copyAndExclude([ castorreco, - totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction,ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction, + totemRPLocalReconstruction,totemTimingLocalReconstruction,ctppsDiamondLocalReconstruction, + ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,ctppsProtons, trackerlocalreco ]) fastSim.toReplaceWith(localreco, _fastSim_localreco) diff --git a/Configuration/StandardSequences/python/VtxSmeared.py b/Configuration/StandardSequences/python/VtxSmeared.py index 2495a222f8984..4f279351356ac 100644 --- a/Configuration/StandardSequences/python/VtxSmeared.py +++ b/Configuration/StandardSequences/python/VtxSmeared.py @@ -59,6 +59,10 @@ 'Realistic25ns13TeVEarly2017Collision' : 'IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2017Collision_cfi', 'Realistic25ns13TeVEarly2018Collision' : 'IOMC.EventVertexGenerators.VtxSmearedRealistic25ns13TeVEarly2018Collision_cfi', 'RealisticPbPbCollision2018' : 'IOMC.EventVertexGenerators.VtxSmearedRealisticPbPbCollision2018_cfi', + 'Run3RoundOptics25ns13TeVLowSigmaZ' : 'IOMC.EventVertexGenerators.VtxSmearedRun3RoundOptics25ns13TeVLowSigmaZ_cfi', + 'Run3RoundOptics25ns13TeVHighSigmaZ' : 'IOMC.EventVertexGenerators.VtxSmearedRun3RoundOptics25ns13TeVHighSigmaZ_cfi', + 'Run3FlatOpticsGaussSigmaZ4p2cm' : 'IOMC.EventVertexGenerators.VtxSmearedRun3FlatOpticsGaussSigmaZ4p2cm_cfi', + 'Run3FlatOpticsGaussSigmaZ5p3cm' : 'IOMC.EventVertexGenerators.VtxSmearedRun3FlatOpticsGaussSigmaZ5p3cm_cfi', } VtxSmearedDefaultKey='Realistic50ns13TeVCollision' VtxSmearedHIDefaultKey='RealisticPbPbCollision2018' diff --git a/DQM/CTPPS/plugins/BuildFile.xml b/DQM/CTPPS/plugins/BuildFile.xml index fbcd2d5b145f3..7b4aefff06d87 100644 --- a/DQM/CTPPS/plugins/BuildFile.xml +++ b/DQM/CTPPS/plugins/BuildFile.xml @@ -7,11 +7,12 @@ + - + diff --git a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc index aad61d485e686..807323b605b03 100644 --- a/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSCommonDQMSource.cc @@ -20,6 +20,7 @@ #include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" #include "DataFormats/OnlineMetaData/interface/CTPPSRecord.h" #include @@ -29,25 +30,32 @@ class CTPPSCommonDQMSource: public one::DQMEDAnalyzer>> { public: - CTPPSCommonDQMSource(const edm::ParameterSet& ps); - ~CTPPSCommonDQMSource() override; protected: - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override; std::shared_ptr> globalBeginLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) const override; void globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) override; + void analyzeCTPPSRecord(edm::Event const& event, edm::EventSetup const& eventSetup); + void analyzeTracks(edm::Event const& event, edm::EventSetup const& eventSetup); + void analyzeProtons(edm::Event const& event, edm::EventSetup const& eventSetup); + private: const unsigned int verbosity; constexpr static int MAX_LUMIS = 6000; constexpr static int MAX_VBINS = 18; - const edm::EDGetTokenT< std::vector > tokenLocalTrackLite; const edm::EDGetTokenT ctppsRecordToken; + const edm::EDGetTokenT< std::vector > tokenLocalTrackLite; + const edm::EDGetTokenT> tokenRecoProtons; + + int currentLS; + int endLS; + + std::vector rpstate; /// plots related to the whole system struct GlobalPlots @@ -69,6 +77,22 @@ class CTPPSCommonDQMSource: public one::DQMEDAnalyzer trackingRPPlots; + + struct TimingRPPlots + { + MonitorElement *h_x, *h_time; + }; + + std::map timingRPPlots; + ArmPlots(){} ArmPlots(DQMStore::IBooker &ibooker, int _id); @@ -95,6 +119,13 @@ void CTPPSCommonDQMSource::GlobalPlots::Init(DQMStore::IBooker &ibooker) events_per_bx = ibooker.book1D("events per BX", "rp;Event.BX", 4002, -1.5, 4000. + 0.5); events_per_bx_short = ibooker.book1D("events per BX (short)", "rp;Event.BX", 102, -1.5, 100. + 0.5); + /* + RP State (HV & LV & Insertion): + 0 -> not used + 1 -> bad + 2 -> warning + 3 -> ok + */ RPState = ibooker.book2D("rpstate per LS","RP State per Lumisection;Luminosity Section;",MAX_LUMIS, 0, MAX_LUMIS, MAX_VBINS, 0., MAX_VBINS); { TH2F* hist = RPState->getTH2F(); @@ -183,6 +214,33 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : xa->SetBinLabel( 5, "220, far, hor"); ya->SetBinLabel( 5, "220, far, hor"); xa->SetBinLabel( 6, "220, far, top"); ya->SetBinLabel( 6, "220, far, top"); xa->SetBinLabel( 7, "220, far, bot"); ya->SetBinLabel( 7, "220, far, bot"); + + h_proton_xi = ibooker.book1D("proton xi", title+";xi", 100, 0., 0.3); + h_proton_t = ibooker.book1D("proton t", title+";|t| GeV^{2}", 100, 0., 5.); + h_proton_time = ibooker.book1D("proton time", title+";time (ns)", 100, -25., 50.); + + for (const unsigned int &rpDecId : { 2, 3, 16, 23 }) + { + unsigned int st = rpDecId / 10, rp = rpDecId % 10, rpFullDecId = id * 100 + rpDecId; + CTPPSDetId rpId(CTPPSDetId::sdTrackingStrip, id, st, rp); + string stName, rpName; + rpId.stationName(stName, CTPPSDetId::nShort); + rpId.rpName(rpName, CTPPSDetId::nShort); + rpName = stName + "_" + rpName; + + if (rp == 6) + { + timingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track time histogram", title+"/"+rpName+";track time (ns)", 100, -25., +50.) + }; + } else { + trackingRPPlots[rpFullDecId] = { + ibooker.book1D(rpName + " - track x histogram", title+"/"+rpName+";track x (mm)", 200, 0., 40.), + ibooker.book1D(rpName + " - track y histogram", title+"/"+rpName+";track y (mm)", 200, -20., +20.) + }; + } + } } //---------------------------------------------------------------------------------------------------- @@ -190,10 +248,13 @@ CTPPSCommonDQMSource::ArmPlots::ArmPlots(DQMStore::IBooker &ibooker, int _id) : CTPPSCommonDQMSource::CTPPSCommonDQMSource(const edm::ParameterSet& ps) : verbosity(ps.getUntrackedParameter("verbosity", 0)), - tokenLocalTrackLite{consumes< vector >(ps.getParameter("tagLocalTrackLite"))}, - ctppsRecordToken {consumes(ps.getUntrackedParameter("ctppsmetadata"))} + ctppsRecordToken(consumes(ps.getUntrackedParameter("ctppsmetadata"))), + tokenLocalTrackLite(consumes< vector >(ps.getParameter("tagLocalTrackLite"))), + tokenRecoProtons(consumes>(ps.getParameter("tagRecoProtons"))) { - + currentLS = 0; + endLS = 0; + rpstate.clear(); } //---------------------------------------------------------------------------------------------------- @@ -220,62 +281,48 @@ void CTPPSCommonDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run c void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) { + analyzeCTPPSRecord(event, eventSetup); + analyzeTracks(event, eventSetup); + analyzeProtons(event, eventSetup); +} - // get CTPPS Event Record - Handle rp; - event.getByToken(ctppsRecordToken, rp); +//---------------------------------------------------------------------------------------------------- - /* - RP State (HV & LV & Insertion): - 0 -> not used - 1 -> bad - 2 -> warning - 3 -> ok +void CTPPSCommonDQMSource::analyzeCTPPSRecord(edm::Event const& event, edm::EventSetup const& eventSetup) +{ + Handle hCTPPSRecord; + event.getByToken(ctppsRecordToken, hCTPPSRecord); + + if (!hCTPPSRecord.isValid()) + { + if (verbosity) + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeCTPPSRecord > input not available."; - CTPPSRecord Order: - RP name: RP_45_210_FR_BT - RP name: RP_45_210_FR_HR - RP name: RP_45_210_FR_TP - RP name: RP_45_220_C1 - RP name: RP_45_220_FR_BT - RP name: RP_45_220_FR_HR - RP name: RP_45_220_FR_TP - RP name: RP_45_220_NR_BT - RP name: RP_45_220_NR_TP - RP name: RP_56_210_FR_BT - RP name: RP_56_210_FR_HR - RP name: RP_56_210_FR_TP - RP name: RP_56_220_C1 - RP name: RP_56_220_FR_BT - RP name: RP_56_220_FR_HR - RP name: RP_56_220_FR_TP - RP name: RP_56_220_NR_BT - RP name: RP_56_220_NR_TP - */ + return; + } auto& rpstate = *luminosityBlockCache(event.getLuminosityBlock().index()); - if(rpstate.empty()){ + if (rpstate.empty()) + { rpstate.reserve(CTPPSRecord::RomanPot::Last); - for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) { - rpstate.push_back(rp->status(i)); - } + for (uint8_t i = 0; i < CTPPSRecord::RomanPot::Last; ++i) + rpstate.push_back(hCTPPSRecord->status(i)); } +} + +//---------------------------------------------------------------------------------------------------- +void CTPPSCommonDQMSource::analyzeTracks(edm::Event const& event, edm::EventSetup const& eventSetup) +{ // get event data - Handle< vector > tracks; - event.getByToken(tokenLocalTrackLite, tracks); + Handle< vector > hTracks; + event.getByToken(tokenLocalTrackLite, hTracks); // check validity - bool valid = true; - valid &= tracks.isValid(); - - if (!valid) + if (!hTracks.isValid()) { if (verbosity) - { - LogProblem("CTPPSCommonDQMSource") - << " trackLites.isValid = " << tracks.isValid(); - } + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeTracks > input not available."; return; } @@ -285,7 +332,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons set s_rp_idx_global_hor, s_rp_idx_global_vert; map> ms_rp_idx_arm; - for (auto &tr : *tracks) + for (auto &tr : *hTracks) { const CTPPSDetId rpId(tr.getRPId()); const unsigned int arm = rpId.arm(); @@ -300,7 +347,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons if (stRPNum == 16) idx = 2; if (idx >= 0) - s_rp_idx_global_hor.insert(3*arm + idx); + s_rp_idx_global_hor.insert(3*arm + idx); } { @@ -311,7 +358,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons if (stRPNum == 25) idx = 3; if (idx >= 0) - s_rp_idx_global_vert.insert(4*arm + idx); + s_rp_idx_global_vert.insert(4*arm + idx); } { @@ -327,7 +374,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons const signed int hor = ((rpNum == 2) || (rpNum == 3) || (rpNum == 6)) ? 1 : 0; if (idx >= 0) - ms_rp_idx_arm[arm].insert(idx * 10 + hor); + ms_rp_idx_arm[arm].insert(idx * 10 + hor); } } @@ -350,7 +397,7 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons map> mTop, mHor, mBot; - for (auto &tr : *tracks) + for (auto &tr : *hTracks) { CTPPSDetId rpId(tr.getRPId()); const unsigned int rpNum = rpId.rp(); @@ -362,6 +409,29 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons mHor[armIdx].insert(rpId); if (rpNum == 1 || rpNum == 5) mBot[armIdx].insert(rpId); + + auto &ap = armPlots[rpId.arm()]; + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + // fill in reference tracking-RP plots + { + auto it = ap.trackingRPPlots.find(rpDecId); + if (it != ap.trackingRPPlots.end()) + { + it->second.h_x->Fill(tr.getX()); + it->second.h_y->Fill(tr.getY()); + } + } + + // fill in reference timing-RP plots + { + auto it = ap.timingRPPlots.find(rpDecId); + if (it != ap.timingRPPlots.end()) + { + it->second.h_x->Fill(tr.getX()); + it->second.h_time->Fill(tr.getTime()); + } + } } for (auto &p : armPlots) @@ -371,7 +441,9 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons p.second.h_numRPWithTrack_bot->Fill(mBot[p.first].size()); } - // track RP correlation + //------------------------------ + // Correlation plots + for (const auto &ap : ms_rp_idx_arm) { auto &plots = armPlots[ap.first]; @@ -380,31 +452,71 @@ void CTPPSCommonDQMSource::analyze(edm::Event const& event, edm::EventSetup cons { for (const auto &idx2 : ap.second) { - plots.h_trackCorr->Fill(idx1/10, idx2/10); + plots.h_trackCorr->Fill(idx1/10, idx2/10); - if ((idx1 % 10) != (idx2 % 10)) - plots.h_trackCorr_overlap->Fill(idx1/10, idx2/10); + if ((idx1 % 10) != (idx2 % 10)) + plots.h_trackCorr_overlap->Fill(idx1/10, idx2/10); } } } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSCommonDQMSource::analyzeProtons(edm::Event const& event, edm::EventSetup const& eventSetup) +{ + // get event data + Handle> hRecoProtons; + event.getByToken(tokenRecoProtons, hRecoProtons); + // check validity + if (!hRecoProtons.isValid()) + { + if (verbosity) + LogProblem("CTPPSCommonDQMSource") << "ERROR in CTPPSCommonDQMSource::analyzeProtons > input not available."; + + return; + } + + // loop over protons + for (auto &p : *hRecoProtons) + { + if (!p.validFit()) + continue; + + signed int armIndex = -1; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector45) + armIndex = 0; + if (p.lhcSector() == reco::ForwardProton::LHCSector::sector56) + armIndex = 1; + if (armIndex < 0) + continue; + + auto &plots = armPlots[armIndex]; + + plots.h_proton_xi->Fill(p.xi()); + plots.h_proton_t->Fill(fabs(p.t())); + plots.h_proton_time->Fill(p.time()); + } } + //---------------------------------------------------------------------------------------------------- -std::shared_ptr> CTPPSCommonDQMSource::globalBeginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& ) const { +std::shared_ptr> CTPPSCommonDQMSource::globalBeginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& ) const +{ return std::make_shared>(); } //---------------------------------------------------------------------------------------------------- -void CTPPSCommonDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) { - +void CTPPSCommonDQMSource::globalEndLuminosityBlock(const edm::LuminosityBlock& iLumi, const edm::EventSetup& c) +{ auto const& rpstate = *luminosityBlockCache(iLumi.index()); auto currentLS = iLumi.id().luminosityBlock(); - for(std::vector::size_type i=0; i::size_type i=0; isetBinContent(currentLS, i+1, rpstate[i]); - } } + //---------------------------------------------------------------------------------------------------- DEFINE_FWK_MODULE(CTPPSCommonDQMSource); diff --git a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc index d9ddbe08eaf4b..4adf728397fd5 100644 --- a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc @@ -491,16 +491,22 @@ CTPPSDiamondDQMSource::analyze( const edm::Event& event, const edm::EventSetup& // check validity bool valid = true; valid &= diamondVFATStatus.isValid(); + valid &= pixelTracks.isValid(); valid &= diamondDigis.isValid(); valid &= fedInfo.isValid(); + valid &= diamondRecHits.isValid(); + valid &= diamondLocalTracks.isValid(); if ( !valid ) { if ( verbosity_ ) { edm::LogProblem("CTPPSDiamondDQMSource") << "ERROR in CTPPSDiamondDQMSource::analyze > some of the required inputs are not valid. Skipping this event.\n" << " diamondVFATStatus.isValid = " << diamondVFATStatus.isValid() << "\n" + << " pixelTracks.isValid = " << pixelTracks.isValid() << "\n" << " diamondDigis.isValid = " << diamondDigis.isValid() << "\n" - << " fedInfo.isValid = " << fedInfo.isValid(); + << " fedInfo.isValid = " << fedInfo.isValid() << "\n" + << " diamondRecHits.isValid = " << diamondRecHits.isValid() << "\n" + << " diamondLocalTracks.isValid = " << diamondLocalTracks.isValid(); } return; diff --git a/DQM/CTPPS/plugins/TotemRPDQMSource.cc b/DQM/CTPPS/plugins/TotemRPDQMSource.cc index be3e06f058aae..62a42b8ad6397 100644 --- a/DQM/CTPPS/plugins/TotemRPDQMSource.cc +++ b/DQM/CTPPS/plugins/TotemRPDQMSource.cc @@ -198,21 +198,20 @@ void TotemRPDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const // loop over arms for (unsigned int arm : {0, 1}) { - // loop over stations - for (unsigned int st : {0, 2}) + // loop over RPs + for (unsigned int st_rp : {2, 3, 4, 5, 24, 25}) { - // loop over RPs - for (unsigned int rp : {4, 5}) - { - TotemRPDetId rpId(arm, st, rp); - potPlots[rpId] = PotPlots(ibooker, rpId); + const unsigned int st = st_rp / 10; + const unsigned int rp = st_rp % 10; - // loop over planes - for (unsigned int pl = 0; pl < 10; ++pl) - { - TotemRPDetId plId(arm, st, rp, pl); - planePlots[plId] = PlanePlots(ibooker, plId); - } + TotemRPDetId rpId(arm, st, rp); + potPlots[rpId] = PotPlots(ibooker, rpId); + + // loop over planes + for (unsigned int pl = 0; pl < 10; ++pl) + { + TotemRPDetId plId(arm, st, rp, pl); + planePlots[plId] = PlanePlots(ibooker, plId); } } } diff --git a/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py b/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py index 71ed040b976ad..1e93a8d0182d0 100644 --- a/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py +++ b/DQM/CTPPS/python/ctppsCommonDQMSource_cfi.py @@ -3,7 +3,8 @@ from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer ctppsCommonDQMSource = DQMEDAnalyzer('CTPPSCommonDQMSource', - tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer'), ctppsmetadata = cms.untracked.InputTag("onlineMetaDataDigis"), + tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer'), + tagRecoProtons = cms.InputTag("ctppsProtons", "multiRP"), verbosity = cms.untracked.uint32(0), ) diff --git a/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py b/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py index ff3ae6b8dfa19..e11ff031bd276 100644 --- a/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py +++ b/DQM/CTPPS/test/all_ctpps_dqm_test_from_aod_cfg.py @@ -6,8 +6,8 @@ # minimum of logs process.MessageLogger = cms.Service("MessageLogger", statistics = cms.untracked.vstring(), - destinations = cms.untracked.vstring('cerr'), - cerr = cms.untracked.PSet( + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( threshold = cms.untracked.string('WARNING') ) ) @@ -26,7 +26,7 @@ process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_hlt_relval', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') # raw data source process.source = cms.Source("PoolSource", @@ -40,14 +40,18 @@ input = cms.untracked.int32(-1) ) -# geometry definition -process.load("Geometry.VeryForwardGeometry.geometryRPFromDB_cfi") +# geometry definition and reco modules +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") # CTPPS DQM modules process.load("DQM.CTPPS.ctppsDQM_cff") process.path = cms.Path( - process.ctppsDQMElastic + process.ctppsPixelLocalReconstruction + * process.ctppsLocalTrackLiteProducer + * process.ctppsProtons + + * process.ctppsDQMElastic ) process.end_path = cms.EndPath( diff --git a/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py b/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py index 52bd28b6734c3..b8e07878ee2ed 100644 --- a/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py +++ b/DQM/CTPPS/test/all_ctpps_dqm_test_from_raw_cfg.py @@ -22,19 +22,29 @@ # raw data source process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - # run 274199, fill 4961, 29 May 2016 (before TS2) - #'/store/data/Run2016B/DoubleEG/RAW/v2/000/274/199/00000/04985451-9B26-E611-BEB9-02163E013859.root', - #'root://eostotem.cern.ch//eos/totem/user/j/jkaspar/04C8034A-9626-E611-9B6E-02163E011F93.root' + # reference for 2016, pre-TS2 (fill 5029) + #"/store/data/Run2016B/ZeroBias/RAW/v2/000/275/371/00000/FA67145B-8836-E611-8560-02163E012627.root", + #"/store/data/Run2016B/ZeroBias/RAW/v2/000/275/371/00000/EAD70032-8836-E611-8C11-02163E014154.root", + "/store/data/Run2016B/DoubleEG/RAW/v2/000/275/371/00000/FE9F0F13-9436-E611-8F39-02163E012B47.root", # temporarily use a staged file from a different stream - # run 283877, fill 5442, 23 Oct 2016 (after TS2) - #'/store/data/Run2016H/HLTPhysics/RAW/v1/000/283/877/00000/F28F8896-999B-E611-93D8-02163E013706.root', + # referece for 2016, post-TS2 (fill 5424) + #"/store/data/Run2016H/ZeroBias/RAW/v1/000/283/453/00000/463B84C2-C098-E611-8BC4-FA163E3201B4.root", + #"/store/data/Run2016H/ZeroBias/RAW/v1/000/283/453/00000/3204EE5B-C298-E611-BC39-02163E01448F.root", + "/store/data/Run2016H/SingleMuon/RAW/v1/000/283/453/00000/FE53CBFE-CB98-E611-A106-FA163E04425A.root", # temporarily use a staged file from a different stream - # test file for 2017 mapping (vertical RPs only) - #'root://eostotem.cern.ch//eos/totem/data/ctpps/run290874.root' + # referece for 2017, pre-TS2 (fill 6089) + "/store/data/Run2017C/ZeroBias/RAW/v1/000/301/283/00000/8ED63519-2282-E711-9073-02163E01A3C6.root", + #"/store/data/Run2017C/ZeroBias/RAW/v1/000/301/283/00000/D4508469-2282-E711-82A9-02163E01A31A.root", - # 900GeV test, 8 May 2018 - '/store/data/Run2018A/Totem1/RAW/v1/000/315/956/00000/B2AB3BFA-8D53-E811-ACFA-FA163E63AE40.root' + # referece for 2017, post-TS2 (fill 6300) + "/store/data/Run2017F/ZeroBias/RAW/v1/000/305/081/00000/001D08EE-C4B1-E711-B92D-02163E013864.root", + #"/store/data/Run2017F/ZeroBias/RAW/v1/000/305/081/00000/44B0284D-C3B1-E711-BECF-02163E014357.root", + + # referece for 2018 (fill 7006) + "/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/601A721D-AD95-E811-B21A-FA163E28A50A.root", + #"/store/data/Run2018D/ZeroBias/RAW/v1/000/320/688/00000/EE97DF44-AD95-E811-A444-02163E019FF7.root", ), + inputCommands = cms.untracked.vstring( 'drop *', 'keep FEDRawDataCollection_*_*_*' @@ -42,7 +52,7 @@ ) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(8000) + input = cms.untracked.int32(-1) ) # global tag - conditions for P5 cluster @@ -52,7 +62,7 @@ process.load("EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff") # local RP reconstruction chain with standard settings -process.load("RecoCTPPS.Configuration.recoCTPPS_DD_cff") +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") # CTPPS DQM modules process.load("DQM.CTPPS.ctppsDQM_cff") diff --git a/DQM/GEM/plugins/GEMDQMStatusDigi.cc b/DQM/GEM/plugins/GEMDQMStatusDigi.cc index c3af8d921fa91..bdfdaacbc0555 100644 --- a/DQM/GEM/plugins/GEMDQMStatusDigi.cc +++ b/DQM/GEM/plugins/GEMDQMStatusDigi.cc @@ -12,9 +12,9 @@ #include "DQMServices/Core/interface/DQMStore.h" #include "DQMServices/Core/interface/MonitorElement.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" #include @@ -40,53 +40,23 @@ class GEMDQMStatusDigi: public DQMEDAnalyzer edm::EDGetToken tagGEB_; edm::EDGetToken tagAMC_; - int AMCBinN(uint16_t BID_); - int GEBBinN(uint16_t BID_); - - MonitorElement *h1B1010All_; - MonitorElement *h1B1100All_; - MonitorElement *h1B1110All_; - - MonitorElement *h1FlagAll_; - MonitorElement *h1CRCAll_; - - MonitorElement *h1InputID_; - MonitorElement *h1Vwh_; - MonitorElement *h1Vwt_; - - MonitorElement *h1GEBError_; - MonitorElement *h1GEBWarning_; - - MonitorElement *h2B1010All_; - MonitorElement *h2B1100All_; - MonitorElement *h2B1110All_; - - MonitorElement *h2FlagAll_; - MonitorElement *h2CRCAll_; - - MonitorElement *h2InputID_; - MonitorElement *h2Vwh_; - MonitorElement *h2Vwt_; - - MonitorElement *h2GEBError_; - MonitorElement *h2GEBWarning_; - - MonitorElement *GEMDAV_; - MonitorElement *Tstate_; - MonitorElement *GDcount_; - MonitorElement *ChamT_; - MonitorElement *OOSG_; + MonitorElement *h1_vfat_quality_; + MonitorElement *h1_vfat_flag_; + MonitorElement *h2_vfat_quality_; + MonitorElement *h2_vfat_flag_; - MonitorElement *GEMDAV2D_; - MonitorElement *Tstate2D_; - MonitorElement *GDcount2D_; - MonitorElement *ChamT2D_; - MonitorElement *OOSG2D_; + MonitorElement *h1_geb_inputStatus_; + MonitorElement *h1_geb_vfatWordCnt_; + MonitorElement *h1_geb_zeroSupWordsCnt_; + MonitorElement *h1_geb_stuckData_; + MonitorElement *h1_geb_inFIFOund_; - std::unordered_map mlAMCID_; - std::unordered_map mlGEBID_; + MonitorElement *h1_amc_ttsState_; + MonitorElement *h1_amc_davCnt_; + MonitorElement *h1_amc_buffState_; + MonitorElement *h1_amc_oosGlib_; + MonitorElement *h1_amc_chTimeOut_; - }; using namespace std; @@ -96,8 +66,8 @@ GEMDQMStatusDigi::GEMDQMStatusDigi(const edm::ParameterSet& cfg) { tagVFAT_ = consumes(cfg.getParameter("VFATInputLabel")); - tagGEB_ = consumes(cfg.getParameter("GEBInputLabel")); - tagAMC_ = consumes(cfg.getParameter("AMCInputLabel")); + tagGEB_ = consumes(cfg.getParameter("GEBInputLabel")); + tagAMC_ = consumes(cfg.getParameter("AMCInputLabel")); } @@ -110,218 +80,78 @@ void GEMDQMStatusDigi::fillDescriptions(edm::ConfigurationDescriptions & descrip descriptions.add("GEMDQMStatusDigi", desc); } -int GEMDQMStatusDigi::AMCBinN(uint16_t BID_) { - - if(mlAMCID_.find(BID_) == mlAMCID_.end()){ - int addIdx = mlAMCID_.size(); - mlAMCID_[BID_] = addIdx; - - int nNumAMC = (int)mlAMCID_.size(); - string strLabel = "BID: "+to_string(BID_); - const char* tmpLabel = strLabel.data(); - ( (TH2F *)GEMDAV2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC); - ( (TH2F *)GEMDAV2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)Tstate2D_->getTH2F() )->SetBins(15, 0, 15, nNumAMC, 0, nNumAMC); - ( (TH2F *)Tstate2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)GDcount2D_->getTH2F() )->SetBins(32, 0, 32, nNumAMC, 0, nNumAMC); - ( (TH2F *)GDcount2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)ChamT2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC); - ( (TH2F *)ChamT2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - - ( (TH2F *)OOSG2D_->getTH2F() )->SetBins(1, 0, 1, nNumAMC, 0, nNumAMC); - ( (TH2F *)OOSG2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel); - } - - return mlAMCID_[BID_]; -} - -int GEMDQMStatusDigi::GEBBinN(uint16_t BID_){ - if(mlGEBID_.find(BID_) == mlGEBID_.end()){ - int addIdx = mlGEBID_.size(); - mlGEBID_[BID_] = addIdx; - - int nNumGEB = (int)mlGEBID_.size(); - string strLabel = "BID: "+to_string(BID_); - const char* tmpLabel = strLabel.data(); - ( (TH2F *)h2B1010All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1010All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2B1100All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1100All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2B1110All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2B1110All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2FlagAll_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2FlagAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2CRCAll_->getTH2F() )->SetBins(0xffff, -32768, 32768, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2CRCAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2InputID_->getTH2F() )->SetBins(31, 0x0 , 0b11111, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2InputID_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2Vwh_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2Vwh_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2Vwt_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2Vwt_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2GEBError_->getTH2F() )->SetBins(5, 0, 5, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2GEBError_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - ( (TH2F *)h2GEBWarning_->getTH2F() )->SetBins(10, 0, 10, nNumGEB, 0, nNumGEB); - ( (TH2F *)h2GEBWarning_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel); - - } - return mlGEBID_[BID_]; -} - -//---------------------------------------------------------------------------------------------------- - - void GEMDQMStatusDigi::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const & iSetup) { ibooker.cd(); ibooker.setCurrentFolder("GEM/StatusDigi"); - h1B1010All_ = ibooker.book1D("vfatErrors_all_b1010", "Control Bit 1010", 15, 0x0 , 0xf); - h1B1100All_ = ibooker.book1D("vfatErrors_all_b1100", "Control Bit 1100", 15, 0x0 , 0xf); - h1B1110All_ = ibooker.book1D("vfatErrors_all_b1110", "Control Bit 1110", 15, 0x0 , 0xf); - h2B1010All_ = ibooker.book2D("vfatErrors_all_b1010_PerGEB", "Control Bit 1010", 15, 0x0 , 0xf, 1, 0, 1); - h2B1100All_ = ibooker.book2D("vfatErrors_all_b1100_PerGEB", "Control Bit 1100", 15, 0x0 , 0xf, 1, 0, 1); - h2B1110All_ = ibooker.book2D("vfatErrors_all_b1110_PerGEB", "Control Bit 1110", 15, 0x0 , 0xf, 1, 0, 1); - - h1FlagAll_ = ibooker.book1D("vfatErrors_all_flag", "Control Flags", 15, 0x0 , 0xf); - h1CRCAll_ = ibooker.book1D("vfatErrors_all_CRC", "CRC Mismatches", 0xffff, -32768, 32768); - h2FlagAll_ = ibooker.book2D("vfatErrors_all_flag_PerGEB", "Control Flags", 15, 0x0 , 0xf, 1, 0, 1); - h2CRCAll_ = ibooker.book2D("vfatErrors_all_CRC_PerGEB", "CRC Mismatches", 0xffff, -32768, 32768, 1, 0, 1); - - h1InputID_ = ibooker.book1D("GEB_InputID", "GEB GLIB input ID", 31, 0x0 , 0b11111); - h1Vwh_ = ibooker.book1D("VFAT_Vwh", "VFAT word count", 4095, 0x0 , 0xfff); - h1Vwt_ = ibooker.book1D("VFAT_Vwt", "VFAT word count", 4095, 0x0 , 0xfff); - h2InputID_ = ibooker.book2D("GEB_InputID_PerGEB", "GEB GLIB input ID", 31, 0x0 , 0b11111, 1, 0, 1); - h2Vwh_ = ibooker.book2D("VFAT_Vwh_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1); - h2Vwt_ = ibooker.book2D("VFAT_Vwt_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1); - - h1GEBError_ = ibooker.book1D("GEB_Errors", "GEB Critical Errors", 5, 0, 5); - h2GEBError_ = ibooker.book2D("GEB_Errors_PerGEB", "GEB Critical Errors", 5, 0, 5, 1, 0, 1); - TH1F *histErr1D = h1GEBError_->getTH1F(); - TH2F *histErr2D = h2GEBError_->getTH2F(); - const char *error_flags[5] = {"Event Size Overflow", "L1AFIFO Full", "InFIFO Full", "Evt FIFO Full","InFIFO Underflow"}; - for (int i = 1; i< histErr1D->GetNbinsX()+1; i++) {histErr1D->GetXaxis()->SetBinLabel(i, error_flags[i-1]); histErr2D->GetXaxis()->SetBinLabel(i, error_flags[i-1]);} - h1GEBWarning_ = ibooker.book1D("GEB_Warnings", "GEB Warnings", 10, 0, 10); - h2GEBWarning_ = ibooker.book2D("GEB_Warnings_PerGEB", "GEB Warnings", 10, 0, 10, 1, 0, 1); - TH1F *histWar1D = h1GEBWarning_->getTH1F(); - TH2F *histWar2D = h2GEBWarning_->getTH2F(); - const char *warning_flags[10] = {"BX AMC-OH Mismatch", "BX AMC-VFAT Mismatch", "OOS AMC OH", "OOS AMC VFAT","No VFAT Marker","Event Size Warn", "L1AFIFO Near Full", "InFIFO Near Full", "EvtFIFO Near Full", "Stuck Data"}; - for (int i = 1; iGetNbinsX()+1; i++) {histWar1D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]); histWar2D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]);} - - GEMDAV_ = ibooker.book1D("GEMDAV", "GEM DAV list", 24, 0, 24); - Tstate_ = ibooker.book1D("Tstate", "TTS state", 15, 0, 15); - GDcount_ = ibooker.book1D("GDcount", "GEM DAV count", 32, 0, 32); - ChamT_ = ibooker.book1D("ChamT", "Chamber Timeout", 24, 0, 24); - OOSG_ = ibooker.book1D("OOSG", "OOS GLIB", 1, 0, 1); - - GEMDAV2D_ = ibooker.book2D("GEMDAV_PerAMC", "GEM DAV list", 24, 0, 24, 1, 0, 1); - Tstate2D_ = ibooker.book2D("Tstate_PerAMC", "TTS state", 15, 0, 15, 1, 0, 1); - GDcount2D_ = ibooker.book2D("GDcount_PerAMC", "GEM DAV count", 32, 0, 32, 1, 0, 1); - ChamT2D_ = ibooker.book2D("ChamT_PerAMC", "Chamber Timeout", 24, 0, 24, 1, 0, 1); - OOSG2D_ = ibooker.book2D("OOSG_PerAMC", "OOS GLIB", 1, 0, 1, 1, 0, 1); + h1_vfat_quality_ = ibooker.book1D("vfat quality", "quality", 6, 0, 6); + h1_vfat_flag_ = ibooker.book1D("vfat flag", "flag", 5, 0, 5); + + h2_vfat_quality_ = ibooker.book2D("vfat quality per geb", "quality", 6, 0 , 6, 36, 0, 36); + h2_vfat_flag_ = ibooker.book2D("vfat flag per geb", "flag", 5, 0, 5, 36, 0, 36); + + h1_geb_inputStatus_ = ibooker.book1D("geb input status", "inputStatus", 10, 0, 10); + h1_geb_vfatWordCnt_ = ibooker.book1D("geb no. vfats", "nvfats", 25, 0, 25); + h1_geb_zeroSupWordsCnt_ = ibooker.book1D("geb zeroSupWordsCnt", "zeroSupWordsCnt", 10, 0, 10); + h1_geb_stuckData_ = ibooker.book1D("geb stuckData", "stuckData", 10, 0, 10); + h1_geb_inFIFOund_ = ibooker.book1D("geb inFIFOund", "inFIFOund", 10, 0, 10); + + h1_amc_ttsState_ = ibooker.book1D("amc ttsState", "ttsState", 10, 0, 10); + h1_amc_davCnt_ = ibooker.book1D("amc davCnt", "davCnt", 10, 0, 10); + h1_amc_buffState_ = ibooker.book1D("amc buffState", "buffState", 10, 0, 10); + h1_amc_oosGlib_ = ibooker.book1D("amc oosGlib", "oosGlib", 10, 0, 10); + h1_amc_chTimeOut_ = ibooker.book1D("amc chTimeOut", "chTimeOut", 10, 0, 10); } void GEMDQMStatusDigi::analyze(edm::Event const& event, edm::EventSetup const& eventSetup) { edm::Handle gemVFAT; - edm::Handle gemGEB; - edm::Handle gemAMC; - event.getByToken( this->tagVFAT_, gemVFAT); - event.getByToken( this->tagGEB_, gemGEB); - event.getByToken( this->tagAMC_, gemAMC); + edm::Handle gemGEB; + edm::Handle gemAMC; + event.getByToken( tagVFAT_, gemVFAT); + event.getByToken( tagGEB_, gemGEB); + event.getByToken( tagAMC_, gemAMC); for (GEMVfatStatusDigiCollection::DigiRangeIterator vfatIt = gemVFAT->begin(); vfatIt != gemVFAT->end(); ++vfatIt){ + GEMDetId gemid = (*vfatIt).first; + float nIdx = gemid.chamber() + (gemid.layer()-1)/2.0; const GEMVfatStatusDigiCollection::Range& range = (*vfatIt).second; - uint16_t tmpID = (*vfatIt).first; - int nIdx = GEBBinN(tmpID); - for ( auto vfatError = range.first; vfatError != range.second; ++vfatError ) { + for ( auto vfatStat = range.first; vfatStat != range.second; ++vfatStat ) { - h1B1010All_->Fill(vfatError->getB1010()); - h1B1100All_->Fill(vfatError->getB1100()); - h1B1110All_->Fill(vfatError->getB1110()); - h1FlagAll_->Fill(vfatError->getFlag()); - h1CRCAll_->Fill(vfatError->getCrc()); - - h2B1010All_->Fill(vfatError->getB1010(), nIdx); - h2B1100All_->Fill(vfatError->getB1100(), nIdx); - h2B1110All_->Fill(vfatError->getB1110(), nIdx); - h2FlagAll_->Fill(vfatError->getFlag(), nIdx); - h2CRCAll_->Fill(vfatError->getCrc(), nIdx); - } + h1_vfat_quality_->Fill(vfatStat->quality()); + h1_vfat_flag_->Fill(vfatStat->flag()); + h2_vfat_quality_->Fill(vfatStat->quality(), nIdx); + h2_vfat_flag_->Fill(vfatStat->flag(), nIdx); } + } - for (GEMGEBStatusDigiCollection::DigiRangeIterator gebIt = gemGEB->begin(); gebIt != gemGEB->end(); ++gebIt){ - const GEMGEBStatusDigiCollection::Range& range = (*gebIt).second; + for (GEMGEBdataCollection::DigiRangeIterator gebIt = gemGEB->begin(); gebIt != gemGEB->end(); ++gebIt){ + const GEMGEBdataCollection::Range& range = (*gebIt).second; for ( auto GEBStatus = range.first; GEBStatus != range.second; ++GEBStatus ) { - uint16_t tmpID = (*gebIt).first; - h1InputID_->Fill(tmpID); - h1Vwh_->Fill(GEBStatus->getVwh()); - h1Vwt_->Fill(GEBStatus->getVwt()); - int nIdx = GEBBinN(tmpID); - h2InputID_->Fill(tmpID, nIdx); - h2Vwh_->Fill(GEBStatus->getVwh(), nIdx); - h2Vwt_->Fill(GEBStatus->getVwt(), nIdx); - - for ( int bin = 0 ; bin < cBit_ ; bin++ ) { - if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) { - h1GEBWarning_->Fill(bin); - h2GEBWarning_->Fill(bin, nIdx); - } - } - for ( int bin = cBit_ ; bin < eBit_ ; bin++ ) { - if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) { - h1GEBError_->Fill(bin - 9); - h2GEBError_->Fill(bin - 9, nIdx); - } - } + h1_geb_inputStatus_->Fill(GEBStatus->inputStatus()); + h1_geb_vfatWordCnt_->Fill(GEBStatus->vfatWordCnt()/3); + h1_geb_zeroSupWordsCnt_->Fill(GEBStatus->zeroSupWordsCnt()); + h1_geb_stuckData_->Fill(GEBStatus->stuckData()); + h1_geb_inFIFOund_->Fill(GEBStatus->inFIFOund()); - if ( ( GEBStatus->getInFu() & 0x1 ) != 0 ) { - h1GEBError_->Fill(9); - h2GEBError_->Fill(9, nIdx); - } - if ( ( GEBStatus->getStuckd() & 0x1 ) != 0 ) { - h1GEBWarning_->Fill(9); - h2GEBWarning_->Fill(9, nIdx); - } } } - for (GEMAMCStatusDigiCollection::DigiRangeIterator amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt){ - const GEMAMCStatusDigiCollection::Range& range = (*amcIt).second; + for (GEMAMCdataCollection::DigiRangeIterator amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt){ + const GEMAMCdataCollection::Range& range = (*amcIt).second; for ( auto amc = range.first; amc != range.second; ++amc ) { - uint16_t tmpID = (*amcIt).first; - int nIdxAMC = AMCBinN(tmpID); - uint8_t binFired = 0; - for (int bin = 0; bin < nVfat_; bin++){ - binFired = ((amc->GEMDAV() >> bin) & 0x1); - if (binFired) {GEMDAV_->Fill(bin); GEMDAV2D_->Fill(bin, nIdxAMC);} - binFired = ((amc->ChamT() >> bin) & 0x1); - if (binFired) {ChamT_->Fill(bin); ChamT2D_->Fill(bin, nIdxAMC);} - } - - Tstate_->Fill(amc->Tstate()); - GDcount_->Fill(amc->GDcount()); - OOSG_->Fill(amc->OOSG()); - - Tstate2D_->Fill(amc->Tstate(), nIdxAMC); - GDcount2D_->Fill(amc->GDcount(), nIdxAMC); - OOSG2D_->Fill(amc->OOSG(), nIdxAMC); + + h1_amc_ttsState_->Fill(amc->ttsState()); + h1_amc_davCnt_->Fill(amc->davCnt()); + h1_amc_buffState_->Fill(amc->buffState()); + h1_amc_oosGlib_->Fill(amc->oosGlib()); + h1_amc_chTimeOut_->Fill(amc->chTimeOut()); } } + } DEFINE_FWK_MODULE(GEMDQMStatusDigi); diff --git a/DQM/GEM/test/test.py b/DQM/GEM/test/test.py index e6486e9d23ece..75104f7e73482 100644 --- a/DQM/GEM/test/test.py +++ b/DQM/GEM/test/test.py @@ -46,13 +46,13 @@ ############## DB file ################# from CondCore.CondDB.CondDB_cfi import * CondDB.DBParameters.authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb') -CondDB.connect = cms.string('sqlite_fip:DQM/GEM/data/GEMELMap.db') +CondDB.connect = cms.string('sqlite_fip:DQM/GEM/data/GEMeMap.db') process.GEMCabling = cms.ESSource("PoolDBESSource", CondDB, toGet = cms.VPSet(cms.PSet( - record = cms.string('GEMELMapRcd'), - tag = cms.string('GEMELMap_v2') + record = cms.string('GEMeMapRcd'), + tag = cms.string('GEMeMap_v2') )), ) #################################### diff --git a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h index 823edeaf3f932..cf72f9664bfca 100644 --- a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h +++ b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h @@ -152,9 +152,8 @@ class CTPPSLocalTrackLite /// number of points used for fit unsigned short numberOfPointsUsedForFit; - /// time information and uncertainty + /// time information and uncertainty, ns float time, time_unc; - }; #endif diff --git a/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h new file mode 100644 index 0000000000000..c0e3008c4e28c --- /dev/null +++ b/DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan Kašpar + * Laurent Forthomme + * + ****************************************************************************/ + +#ifndef DataFormats_CTPPSReco_CTPPSLocalTrackLiteFwd_h +#define DataFormats_CTPPSReco_CTPPSLocalTrackLiteFwd_h + +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/Common/interface/RefVector.h" + +#include + +class CTPPSLocalTrackLite; +/// Collection of CTPPSLocalTrackLite objects +typedef std::vector CTPPSLocalTrackLiteCollection; +/// Persistent reference to a CTPPSLocalTrackLite +typedef edm::Ref CTPPSLocalTrackLiteRef; +/// Reference to a CTPPSLocalTrackLite collection +typedef edm::RefProd CTPPSLocalTrackLiteRefProd; +/// Vector of references to CTPPSLocalTrackLite in the same collection +typedef edm::RefVector CTPPSLocalTrackLiteRefVector; + +#endif + diff --git a/DataFormats/CTPPSReco/src/classes.h b/DataFormats/CTPPSReco/src/classes.h index b2860d0ac8478..733e00574a143 100644 --- a/DataFormats/CTPPSReco/src/classes.h +++ b/DataFormats/CTPPSReco/src/classes.h @@ -1,5 +1,7 @@ #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/PtrVector.h" +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/DetSet.h" #include "DataFormats/Common/interface/DetSetVector.h" diff --git a/DataFormats/CTPPSReco/src/classes_def.xml b/DataFormats/CTPPSReco/src/classes_def.xml index 5d9ca355a143b..6029635ec5234 100644 --- a/DataFormats/CTPPSReco/src/classes_def.xml +++ b/DataFormats/CTPPSReco/src/classes_def.xml @@ -170,4 +170,8 @@ + + + + diff --git a/DataFormats/Common/interface/AssociativeIterator.h b/DataFormats/Common/interface/AssociativeIterator.h index 0b20974e9b7af..e26609c863e72 100644 --- a/DataFormats/Common/interface/AssociativeIterator.h +++ b/DataFormats/Common/interface/AssociativeIterator.h @@ -40,7 +40,6 @@ #include "DataFormats/Provenance/interface/ProductID.h" #include "DataFormats/Common/interface/EDProductGetter.h" -#include "FWCore/Framework/interface/Event.h" namespace edm { class Event; @@ -74,12 +73,12 @@ namespace edm { /// Helper class that fetches some type of Ref given ProductID and index, using the edm::Event // the implementation uses View, and works for RefType = Ref, RefToBase and Ptr - template - class EdmEventItemGetter { + template + class EventItemGetter { public: typedef typename RefType::value_type element_type; - EdmEventItemGetter(const edm::Event &iEvent) : iEvent_(iEvent) { } - ~EdmEventItemGetter() { } + EventItemGetter(const EventType &iEvent) : iEvent_(iEvent) { } + ~EventItemGetter() { } RefType get(const ProductID &id, size_t idx) const { typedef typename edm::RefToBase BaseRefType; // could also use Ptr, but then I can't do Ptr->RefToBase @@ -94,7 +93,7 @@ namespace edm { private: mutable Handle > view_; mutable ProductID id_; - const edm::Event &iEvent_; + const EventType &iEvent_; }; // unfortunately it's not possible to define value_type of an Association correctly @@ -111,8 +110,7 @@ namespace edm { }; } -template > +template class AssociativeIterator { public: typedef KeyRefType key_type; @@ -228,6 +226,12 @@ class AssociativeIterator { pairOk_ = true; } + template + AssociativeIterator > + makeAssociativeIterator(const AC &map, const EventType &event) { + using Getter = edm::EventItemGetter; + return AssociativeIterator(map, Getter{event}); + } } #endif diff --git a/DataFormats/DetId/src/classes_def.xml b/DataFormats/DetId/src/classes_def.xml index 84b0a4f574db7..7db1607301a92 100644 --- a/DataFormats/DetId/src/classes_def.xml +++ b/DataFormats/DetId/src/classes_def.xml @@ -9,4 +9,8 @@ + + + + diff --git a/DataFormats/EcalDigi/interface/EcalMGPASample.h b/DataFormats/EcalDigi/interface/EcalMGPASample.h index 49fb6f9c756cc..344e48d4b0c80 100644 --- a/DataFormats/EcalDigi/interface/EcalMGPASample.h +++ b/DataFormats/EcalDigi/interface/EcalMGPASample.h @@ -8,10 +8,10 @@ namespace ecalMGPA { typedef uint16_t sample_type; /// get the ADC sample (12 bits) - inline int adc(sample_type sample) { return sample&0xFFF; } + constexpr int adc(sample_type sample) { return sample&0xFFF; } /// get the gainId (2 bits) - inline int gainId(sample_type sample) { return (sample>>12)&0x3; } - inline sample_type pack(int adc, int gainId) { + constexpr int gainId(sample_type sample) { return (sample>>12)&0x3; } + constexpr sample_type pack(int adc, int gainId) { return (adc&0xFFF) | ((gainId&0x3)<<12); } } diff --git a/DataFormats/EgammaReco/src/classes_def.xml b/DataFormats/EgammaReco/src/classes_def.xml index ac9967836bd73..0a72d86b70dd6 100644 --- a/DataFormats/EgammaReco/src/classes_def.xml +++ b/DataFormats/EgammaReco/src/classes_def.xml @@ -156,6 +156,5 @@ - diff --git a/DataFormats/GEMDigi/src/classes.h b/DataFormats/GEMDigi/src/classes.h index 773a0aea87456..f4b398d4bc43d 100644 --- a/DataFormats/GEMDigi/src/classes.h +++ b/DataFormats/GEMDigi/src/classes.h @@ -25,15 +25,6 @@ #include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" #include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" - -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" - -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigi.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" - #include "DataFormats/Common/interface/Wrapper.h" #include diff --git a/DataFormats/GEMDigi/src/classes_def.xml b/DataFormats/GEMDigi/src/classes_def.xml index b9a5e4c5ec894..6955f5c1a4371 100644 --- a/DataFormats/GEMDigi/src/classes_def.xml +++ b/DataFormats/GEMDigi/src/classes_def.xml @@ -9,30 +9,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DataFormats/HepMCCandidate/interface/GenParticleFwd.h b/DataFormats/HepMCCandidate/interface/GenParticleFwd.h index 881b537755a51..3f9bf63ab7791 100755 --- a/DataFormats/HepMCCandidate/interface/GenParticleFwd.h +++ b/DataFormats/HepMCCandidate/interface/GenParticleFwd.h @@ -2,6 +2,9 @@ #define HepMCCandidate_GenParticleFwd_h #include #include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/Common/interface/FwdRef.h" +#include "DataFormats/Common/interface/FwdPtr.h" #include "DataFormats/Common/interface/RefProd.h" #include "DataFormats/Common/interface/RefVector.h" #include "DataFormats/Common/interface/Association.h" @@ -12,12 +15,18 @@ namespace reco { typedef std::vector GenParticleCollection; /// persistent reference to a GenParticle typedef edm::Ref GenParticleRef; + /// persistent reference to a GenParticle + typedef edm::Ptr GenParticlePtr; + /// forward persistent reference to a GenParticle + typedef edm::FwdPtr GenParticleFwdPtr; /// persistent reference to a GenParticle collection typedef edm::RefProd GenParticleRefProd; /// vector of reference to GenParticle in the same collection typedef edm::RefVector GenParticleRefVector; /// vector of reference to GenParticle in the same collection typedef edm::Association GenParticleMatch; + // vector of forward persistent reference to a GenParticle + typedef std::vector GenParticleFwdPtrVector; } #endif diff --git a/DataFormats/HepMCCandidate/src/classes.h b/DataFormats/HepMCCandidate/src/classes.h index ad8a24ea2fac7..c90743bd5fbf3 100755 --- a/DataFormats/HepMCCandidate/src/classes.h +++ b/DataFormats/HepMCCandidate/src/classes.h @@ -11,40 +11,3 @@ #include "DataFormats/HepMCCandidate/interface/FlavorHistoryEvent.h" #include -namespace DataFormats_HepMCCandidate { - struct dictionary { - reco::CompositeRefCandidateT v1; - edm::Wrapper w2; - edm::Wrapper w3; - reco::GenParticleRef r1; - reco::GenParticleRefProd rp1; - edm::Wrapper wrv1; - edm::Wrapper > > wvvg1; - edm::reftobase::Holder hcg1; - edm::reftobase::RefHolder hcg2; - edm::reftobase::VectorHolder hcg3; - edm::reftobase::RefVectorHolder hcg4; - reco::PdfInfo p1; - edm::Wrapper wp1; - reco::FlavorHistory fh1; - std::vector vfh1; - edm::Wrapper > wvfh1; - edm::ValueMap vmfh1; - edm::Wrapper > wvmfh1; - reco::FlavorHistoryEvent fhe1; - std::vector vfhe1; - edm::Wrapper wfhe1; - edm::Wrapper > wvfhe1; - edm::ValueMap vmfhe1; - edm::Wrapper > wvmfhe1; - std::vector v_gpr; - edm::RefVectorIterator,reco::GenParticle,edm::refhelper::FindUsingAdvance,reco::GenParticle> > rvigp; - edm::ValueMap,reco::GenParticle,edm::refhelper::FindUsingAdvance,reco::GenParticle> > > vmgr; - edm::Wrapper,reco::GenParticle,edm::refhelper::FindUsingAdvance,reco::GenParticle> > > > wvmgr; - edm::Ptr gpptr; - edm::FwdPtr gpfp; - std::vector> vgpfp; - edm::Wrapper>> wvgpfp; - }; -} - diff --git a/DataFormats/JetReco/interface/GenJet.h b/DataFormats/JetReco/interface/GenJet.h index 1a51c62b25bed..161326a40a913 100644 --- a/DataFormats/JetReco/interface/GenJet.h +++ b/DataFormats/JetReco/interface/GenJet.h @@ -11,7 +11,8 @@ * * \author Fedor Ratnikov, UMd * - * \version Original March 31, 2006 by F.R. + * \version Original March 31, 2006 by F.R. + * Added GenJet specifics, 2019 by Salvatore Rappoccio ************************************************************/ @@ -26,10 +27,22 @@ class GenJet : public Jet { struct Specific { Specific () : m_EmEnergy (0), - m_HadEnergy (0), - m_InvisibleEnergy (0), - m_AuxiliaryEnergy (0) {} - + m_HadEnergy (0), + m_InvisibleEnergy (0), + m_AuxiliaryEnergy (0), + m_ChargedHadronEnergy(0), + m_NeutralHadronEnergy(0), + m_ChargedEmEnergy(0), + m_NeutralEmEnergy(0), + m_MuonEnergy(0), + m_ChargedHadronMultiplicity(0), + m_NeutralHadronMultiplicity(0), + m_ChargedEmMultiplicity(0), + m_NeutralEmMultiplicity(0), + m_MuonMultiplicity(0) + {} + + /// Calo-like definitions: /// Energy of EM particles float m_EmEnergy; /// Energy of Hadrons @@ -38,6 +51,25 @@ class GenJet : public Jet { float m_InvisibleEnergy; /// Anything else (undecayed Sigmas etc.) float m_AuxiliaryEnergy; + + /// PF-like definitions: + /// pi+, K+, etc + float m_ChargedHadronEnergy; + /// K0, etc + float m_NeutralHadronEnergy; + /// Electrons + float m_ChargedEmEnergy; + /// Photons + float m_NeutralEmEnergy; + /// Muons + float m_MuonEnergy; + /// Corresponding multiplicities: + int m_ChargedHadronMultiplicity; + int m_NeutralHadronMultiplicity; + int m_ChargedEmMultiplicity; + int m_NeutralEmMultiplicity; + int m_MuonMultiplicity; + }; /** Default constructor*/ @@ -62,6 +94,19 @@ class GenJet : public Jet { /** Returns other energy (undecayed Sigmas etc.)*/ float auxiliaryEnergy() const {return m_specific.m_AuxiliaryEnergy;}; + + // PF-like definitions + float chargedHadronEnergy() const { return m_specific.m_ChargedHadronEnergy;} + float neutralHadronEnergy() const { return m_specific.m_NeutralHadronEnergy;} + float chargedEmEnergy () const { return m_specific.m_ChargedEmEnergy ;} + float neutralEmEnergy () const { return m_specific.m_NeutralEmEnergy ;} + float muonEnergy () const { return m_specific.m_MuonEnergy ;} + int chargedHadronMultiplicity() const { return m_specific.m_ChargedHadronMultiplicity;} + int neutralHadronMultiplicity() const { return m_specific.m_NeutralHadronMultiplicity;} + int chargedEmMultiplicity () const { return m_specific.m_ChargedEmMultiplicity ;} + int neutralEmMultiplicity () const { return m_specific.m_NeutralEmMultiplicity ;} + int muonMultiplicity () const { return m_specific.m_MuonMultiplicity ;} + /// Detector Eta (use reference Z and jet kinematics only) float detectorEta (float fZVertex) const; diff --git a/DataFormats/JetReco/src/classes_def_1.xml b/DataFormats/JetReco/src/classes_def_1.xml index 2bb19bb85e47a..f235bc4f88fbd 100644 --- a/DataFormats/JetReco/src/classes_def_1.xml +++ b/DataFormats/JetReco/src/classes_def_1.xml @@ -93,7 +93,8 @@ - + + diff --git a/DataFormats/L1TrackTrigger/src/classes_def.xml b/DataFormats/L1TrackTrigger/src/classes_def.xml index 540bf5ea4ba54..9bc72592804c1 100644 --- a/DataFormats/L1TrackTrigger/src/classes_def.xml +++ b/DataFormats/L1TrackTrigger/src/classes_def.xml @@ -1,10 +1,7 @@ - - - @@ -23,7 +20,6 @@ - diff --git a/DataFormats/Math/test/BuildFile.xml b/DataFormats/Math/test/BuildFile.xml index 160e9df5535f4..6b1112e30472c 100644 --- a/DataFormats/Math/test/BuildFile.xml +++ b/DataFormats/Math/test/BuildFile.xml @@ -43,12 +43,16 @@ - + + + - + + + diff --git a/DataFormats/MuonReco/interface/Muon.h b/DataFormats/MuonReco/interface/Muon.h index ea148da96a4e5..efea9c6477b3d 100755 --- a/DataFormats/MuonReco/interface/Muon.h +++ b/DataFormats/MuonReco/interface/Muon.h @@ -216,7 +216,10 @@ namespace reco { InTimeMuon = 1UL<<23, PFIsoVeryVeryTight = 1UL<<24, // reliso<0.05 MultiIsoLoose = 1UL<<25, // miniIso with ptRatio and ptRel - MultiIsoMedium = 1UL<<26 // miniIso with ptRatio and ptRel + MultiIsoMedium = 1UL<<26, // miniIso with ptRatio and ptRel + PuppiIsoLoose = 1UL<<27, + PuppiIsoMedium = 1UL<<28, + PuppiIsoTight = 1UL<<29 }; bool passed( unsigned int selection ) const { return (selectors_ & selection)==selection; } diff --git a/DataFormats/Phase2TrackerDigi/src/classes_def.xml b/DataFormats/Phase2TrackerDigi/src/classes_def.xml index 46379d3d4421b..1738169b5f698 100644 --- a/DataFormats/Phase2TrackerDigi/src/classes_def.xml +++ b/DataFormats/Phase2TrackerDigi/src/classes_def.xml @@ -2,6 +2,8 @@ + + @@ -13,4 +15,6 @@ + + diff --git a/DataFormats/ProtonReco/BuildFile.xml b/DataFormats/ProtonReco/BuildFile.xml new file mode 100644 index 0000000000000..a54f5cfdd9083 --- /dev/null +++ b/DataFormats/ProtonReco/BuildFile.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/DataFormats/ProtonReco/interface/ForwardProton.h b/DataFormats/ProtonReco/interface/ForwardProton.h new file mode 100644 index 0000000000000..f438c519ea245 --- /dev/null +++ b/DataFormats/ProtonReco/interface/ForwardProton.h @@ -0,0 +1,166 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + +#ifndef DataFormats_ProtonReco_ForwardProton_h +#define DataFormats_ProtonReco_ForwardProton_h + +#include "DataFormats/Math/interface/Error.h" +#include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/Math/interface/Vector3D.h" + +#include "DataFormats/Common/interface/RefVector.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" + +namespace reco +{ + class ForwardProton + { + public: + /// parameter dimension + enum { dimension = 5 }; + /// indices to the covariance matrix + enum struct Index { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension }; + /// dimension-parameter covariance matrix + typedef math::ErrorF::type CovarianceMatrix; + /// spatial vector + typedef math::XYZVectorF Vector; + /// point in the space + typedef math::XYZPointF Point; + /// type of reconstruction applied for this track + enum class ReconstructionMethod { invalid = -1, singleRP, multiRP }; + + public: + /// default constructor + ForwardProton(); + /// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss + ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ); + + /// fitted vertex position + const Point& vertex() const { return vertex_; } + /// fitted vertex horizontal position + float vx() const { return vertex_.x(); } + /// fitted vertex vertical position + float vy() const { return vertex_.y(); } + /// vertex longitudinal position (conventionally set to 0) + float vz() const { return vertex_.z(); } + /// fitted track direction + const Vector& momentum() const { return momentum_; } + /// scalar norm of fitted track momentum + float p() const { return momentum_.r(); } + /// scalar fitted track transverse momentum + float pt() const { return momentum_.rho(); } + /// fitted track momentum horizontal component + float px() const { return momentum_.x(); } + /// fitted track momentum vertical component + float py() const { return momentum_.y(); } + /// fitted track momentum longitudinal component + float pz() const { return momentum_.z(); } + + /// chi-squared of the fit + float chi2() const { return chi2_; } + /// number of degrees of freedom for the track fit + unsigned int ndof() const { return ndof_; } + /// chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero) + float normalizedChi2() const { + return ( ndof_ != 0 ) ? chi2_ / ndof_ : chi2_ * 1.e6; + } + + /// longitudinal fractional momentum loss + float xi() const { return xi_; } + /// vertical scattering angle, in rad + float thetaX() const { return px() / p(); } + /// horizontal scattering angle, in rad + float thetaY() const { return py() / p(); } + + // vertex position can be obtained via TrackBase::vx() and vy() functions + + /// return the uncertainty on a given component + double error( Index i ) const { + return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) ); + } + + /// uncertainty on longitudinal fractional momentum loss + float xiError() const { return error( Index::xi ); } + /// uncertainty on fitted momentum horizontal angle opening + float thetaXError() const { return error( Index::th_x ); } + /// uncertainty on fitted momentum vertical angle opening + float thetaYError() const { return error( Index::th_y ); } + /// uncertainty on fitted vertex horizontal position + float vxError() const { return error( Index::vtx_x ); } + /// uncertainty on fitted vertex vertical position + float vyError() const { return error( Index::vtx_y ); } + + /// proton mass in GeV + static float mass() { return mass_; } + + /// compute the squared four-momentum transfer from incident and scattered momenta, and angular information + static float calculateT( double beam_mom, double proton_mom, double theta ); + + /// four-momentum transfer squared, in GeV^2 + float t() const; + + /// time of proton arrival at forward stations + float time() const { return time_; } + /// uncertainty on time of proton arrival at forward stations + float timeError() const { return time_err_; } + + /// set the flag for the fit validity + void setValidFit( bool valid = true ) { valid_fit_ = valid; } + /// flag for the fit validity + bool validFit() const { return valid_fit_; } + + /// set the reconstruction method for this track + void setMethod( const ReconstructionMethod& method ) { method_ = method; } + /// reconstruction method for this track + ReconstructionMethod method() const { return method_; } + + /// store the list of RP tracks that contributed to this global track + void setContributingLocalTracks( const CTPPSLocalTrackLiteRefVector &v ) { contributing_local_tracks_ = v; } + /// list of RP tracks that contributed to this global track + const CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return contributing_local_tracks_; } + + /// LHC sector + enum class LHCSector { invalid = -1, sector45, sector56 }; + LHCSector lhcSector() const + { + if ( pz() < 0. ) return LHCSector::sector56; + if ( pz() > 0. ) return LHCSector::sector45; + return LHCSector::invalid; + } + + private: + static constexpr float mass_ = 0.938272046; ///< proton mass, GeV + static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2 + + /// reconstructed vertex position at z/s = 0 + Point vertex_; + /// reconstructed momentum vector + Vector momentum_; + /// reconstructed time at forward detectors + float time_; + /// uncertainty on reconstructed time at forward detectors + float time_err_; + /// fractional momentum loss (positive for diffractive protons) + float xi_; + /// 5x5 covariance matrix + CovarianceMatrix covariance_; + /// chi-squared + float chi2_; + /// number of degrees of freedom + unsigned int ndof_; + /// fit validity flag + bool valid_fit_; + /// type of reconstruction applied + ReconstructionMethod method_; + /// collection of references to tracks contributing to this object definition + CTPPSLocalTrackLiteRefVector contributing_local_tracks_; + }; +} + +#endif diff --git a/DataFormats/ProtonReco/interface/ForwardProtonFwd.h b/DataFormats/ProtonReco/interface/ForwardProtonFwd.h new file mode 100644 index 0000000000000..0b09890de88eb --- /dev/null +++ b/DataFormats/ProtonReco/interface/ForwardProtonFwd.h @@ -0,0 +1,33 @@ +/**************************************************************************** + * + * This is a part of CTPPS offline software. + * Authors: + * Jan Kašpar + * Laurent Forthomme + * + ****************************************************************************/ + +#ifndef DataFormats_ProtonReco_ForwardProtonFwd_h +#define DataFormats_ProtonReco_ForwardProtonFwd_h + +#include "DataFormats/Common/interface/Ref.h" +#include "DataFormats/Common/interface/RefProd.h" +#include "DataFormats/Common/interface/RefVector.h" + +#include + +namespace reco +{ + class ForwardProton; + /// Collection of ForwardProton objects + typedef std::vector ForwardProtonCollection; + /// Persistent reference to a ForwardProton + typedef edm::Ref ForwardProtonRef; + /// Reference to a ForwardProton collection + typedef edm::RefProd ForwardProtonRefProd; + /// Vector of references to ForwardProton in the same collection + typedef edm::RefVector ForwardProtonRefVector; +} + +#endif + diff --git a/DataFormats/ProtonReco/src/ForwardProton.cc b/DataFormats/ProtonReco/src/ForwardProton.cc new file mode 100644 index 0000000000000..1a650733cbd8a --- /dev/null +++ b/DataFormats/ProtonReco/src/ForwardProton.cc @@ -0,0 +1,41 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + +#include "DataFormats/ProtonReco/interface/ForwardProton.h" + +#include + +using namespace reco; + +ForwardProton::ForwardProton() : + time_( 0. ), time_err_( 0. ), xi_( 0. ), chi2_( 0. ), ndof_( 0 ), + valid_fit_( false ), method_( ReconstructionMethod::invalid ) +{} + +ForwardProton::ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi, + const CovarianceMatrix& cov, ReconstructionMethod method, + const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid ) : + vertex_( vtx ), momentum_( momentum ), + time_( 0. ), time_err_( 0. ), xi_( xi ), + covariance_( cov ), chi2_( chi2 ), ndof_( ndof ), + valid_fit_( valid ), method_( method ), contributing_local_tracks_( local_tracks ) +{} + +float +ForwardProton::calculateT( double beam_mom, double proton_mom, double theta ) +{ + const double t0 = 2.*( massSquared_+beam_mom*proton_mom-sqrt( ( massSquared_+beam_mom*beam_mom ) * ( massSquared_+proton_mom*proton_mom ) ) ); + const double S = sin(theta/2.); + return t0 - 4. * beam_mom * proton_mom * S*S; +} + +float +ForwardProton::t() const +{ + const double beam_mom = p() / (1.-xi()); + const double theta = std::hypot( thetaX(), thetaY() ); + return calculateT( beam_mom, p(), theta ); +} diff --git a/DataFormats/ProtonReco/src/classes.h b/DataFormats/ProtonReco/src/classes.h new file mode 100644 index 0000000000000..df9677e71ddf4 --- /dev/null +++ b/DataFormats/ProtonReco/src/classes.h @@ -0,0 +1,9 @@ +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" + +#include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/Common/interface/View.h" +#include "DataFormats/Common/interface/Wrapper.h" + +#include +#include diff --git a/DataFormats/ProtonReco/src/classes_def.xml b/DataFormats/ProtonReco/src/classes_def.xml new file mode 100644 index 0000000000000..0e88cf81de42e --- /dev/null +++ b/DataFormats/ProtonReco/src/classes_def.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/DataFormats/TrackReco/interface/HitPattern.h b/DataFormats/TrackReco/interface/HitPattern.h index ad982a59a4d25..0b9732d6c366b 100644 --- a/DataFormats/TrackReco/interface/HitPattern.h +++ b/DataFormats/TrackReco/interface/HitPattern.h @@ -445,6 +445,14 @@ class HitPattern int numberOfDTStationsWithRZView() const; int numberOfDTStationsWithBothViews() const; + //only used by ROOT IO rule to read v12 HitPatterns + static bool fillNewHitPatternWithOldHitPattern_v12(const uint16_t oldHitPattern[], + uint8_t hitCount, + uint8_t beginTrackHits, uint8_t endTrackHits, + uint8_t beginInner, uint8_t endInner, + uint8_t beginOuter, uint8_t endOuter, + reco::HitPattern* newObj); + private: // 3 bits for hit type diff --git a/DataFormats/TrackReco/src/classes_def.xml b/DataFormats/TrackReco/src/classes_def.xml index 114d14de0b8dd..c16b1f80467a8 100644 --- a/DataFormats/TrackReco/src/classes_def.xml +++ b/DataFormats/TrackReco/src/classes_def.xml @@ -29,80 +29,17 @@ > 4); - uint8_t secondWordBits = bitEndOffset & (16 - 1); // that is, bitEndOffset % 32 - if (secondWordBits >= HitSize) { - // full block is in this word - uint8_t lowBitsToTrash = secondWordBits - HitSize; - return (hitPattern[secondWord] >> lowBitsToTrash) & ((1 << HitSize) - 1); - } else { - uint8_t firstWordBits = HitSize - secondWordBits; - uint16_t firstWordBlock = hitPattern[secondWord - 1] >> (16 - firstWordBits); - uint16_t secondWordBlock = hitPattern[secondWord] & ((1 << secondWordBits) - 1); - return firstWordBlock + (secondWordBlock << firstWordBits); - } - }; - - auto appendOldHitPattern = [&](const uint16_t pattern) { - // for this version we just have to add a 0 bit to the top of the pattern - const static unsigned short HitTypeMask = 0x3; - const static unsigned short HitTypeOffset = 0; - - const uint16_t VALID_CONST = (uint16_t) TrackingRecHit::valid; - const uint16_t MISSING_CONST = (uint16_t) TrackingRecHit::missing; - const uint16_t INACTIVE_CONST = (uint16_t) TrackingRecHit::inactive; - const uint16_t BAD_CONST = (uint16_t) TrackingRecHit::bad; - - uint16_t rawHitType = (pattern >> HitTypeOffset) & HitTypeMask; - - TrackingRecHit::Type hitType = TrackingRecHit::valid; - switch (rawHitType) { - case VALID_CONST: - hitType = TrackingRecHit::valid; - break; - case MISSING_CONST: - hitType = TrackingRecHit::missing; - break; - case INACTIVE_CONST: - hitType = TrackingRecHit::inactive; - break; - case BAD_CONST: - hitType = TrackingRecHit::bad; - break; - } - return newObj->appendHit(pattern,hitType); - }; - - auto fillNewHitPatternWithOldHitPattern = [&](const uint16_t oldHitPattern[]) { - newObj->clear(); - for (int i = 0; i < MaxHits; i++) { - uint16_t pattern = getHitFromOldHitPattern(oldHitPattern, i); - if (pattern == 0) { - break; - } - if(!appendOldHitPattern(pattern)) { - return false; - } - } - return true; - }; - - fillNewHitPatternWithOldHitPattern(onfile.hitPattern); + (void) reco::HitPattern::fillNewHitPatternWithOldHitPattern_v12(onfile.hitPattern, *onfile.hitCount, + *onfile.beginTrackHits, *onfile.endTrackHits, + *onfile.beginInner, *onfile.endInner, + *onfile.beginOuter, *onfile.endOuter, + newObj); ]]> > 4); + const uint8_t secondWordBits = bitEndOffset & (16 - 1); // that is, bitEndOffset % 32 + if (secondWordBits >= HitSize) { + // full block is in this word + const uint8_t lowBitsToTrash = secondWordBits - HitSize; + return (hitPattern[secondWord] >> lowBitsToTrash) & ((1 << HitSize) - 1); + } + const uint8_t firstWordBits = HitSize - secondWordBits; + const uint16_t firstWordBlock = hitPattern[secondWord - 1] >> (16 - firstWordBits); + const uint16_t secondWordBlock = hitPattern[secondWord] & ((1 << secondWordBits) - 1); + return firstWordBlock + (secondWordBlock << firstWordBits); + } + + auto hitTypeFromOldHitPattern(const uint16_t pattern) { + // for this version we just have to add a 0 bit to the top of the pattern + constexpr unsigned short HitTypeMask = 0x3; + constexpr unsigned short HitTypeOffset = 0; + + constexpr uint16_t VALID_CONST = (uint16_t) TrackingRecHit::valid; + constexpr uint16_t MISSING_CONST = (uint16_t) TrackingRecHit::missing; + constexpr uint16_t INACTIVE_CONST = (uint16_t) TrackingRecHit::inactive; + constexpr uint16_t BAD_CONST = (uint16_t) TrackingRecHit::bad; + + const uint16_t rawHitType = (pattern >> HitTypeOffset) & HitTypeMask; + + TrackingRecHit::Type hitType = TrackingRecHit::valid; + switch (rawHitType) { + case VALID_CONST: + hitType = TrackingRecHit::valid; + break; + case MISSING_CONST: + hitType = TrackingRecHit::missing; + break; + case INACTIVE_CONST: + hitType = TrackingRecHit::inactive; + break; + case BAD_CONST: + hitType = TrackingRecHit::bad; + break; + } + return hitType; + }; +} + +bool +reco::HitPattern::fillNewHitPatternWithOldHitPattern_v12(const uint16_t oldHitPattern[], + uint8_t hitCount, + uint8_t beginTrackHits, uint8_t endTrackHits, + uint8_t beginInner, uint8_t endInner, + uint8_t beginOuter, uint8_t endOuter, + HitPattern* newObj) { + newObj->clear(); + bool ret = true; + for (int i = 0; i < MaxHitsV12; i++) { + uint16_t pattern = getHitFromOldHitPattern(oldHitPattern, i); + if (pattern == 0) { + break; + } + if(! newObj->appendHit(pattern, hitTypeFromOldHitPattern(pattern)) ) { + ret = false; + break; + } + } + newObj->hitCount = hitCount; + newObj->beginTrackHits =beginTrackHits; + newObj->endTrackHits = endTrackHits; + newObj->beginInner = beginInner; + newObj->endInner = endInner; + newObj->beginOuter = beginOuter; + newObj->endOuter = endOuter; + return ret; +} diff --git a/DataFormats/TrackReco/test/testHitPattern.cpp b/DataFormats/TrackReco/test/testHitPattern.cpp index a088a60b8cd0b..79a55481dca29 100644 --- a/DataFormats/TrackReco/test/testHitPattern.cpp +++ b/DataFormats/TrackReco/test/testHitPattern.cpp @@ -60,6 +60,107 @@ namespace test { assert(hp.numberOfValidTimingHits() == 1); } + { + uint16_t oldHitPattern[50] = {20113, + 44149, + 2321, + 19529, + 37506, + 34993, + 11429, + 12644, + 23051, + 13124, + 26, + 0}; + + + uint8_t hitCount = 15; + uint8_t beginTrackHits = 3; + uint8_t endTrackHits = 15; + uint8_t beginInner = 0; + uint8_t endInner = 0; + uint8_t beginOuter = 0; + uint8_t endOuter = 3; + + HitPattern hp; + HitPattern::fillNewHitPatternWithOldHitPattern_v12(oldHitPattern, hitCount, + beginTrackHits, endTrackHits, + beginInner, endInner, + beginOuter, endOuter, + &hp); + + assert(hp.numberOfValidTrackerHits() ==12 ); + assert(hp.numberOfValidPixelHits() == 4); + assert(hp.numberOfValidPixelBarrelHits() == 4 ); + assert(hp.numberOfValidPixelEndcapHits() == 0); + assert(hp.numberOfValidStripHits() == 8 ); + assert(hp.numberOfValidStripTIBHits() == 6); + assert(hp.numberOfValidStripTIDHits() == 0); + assert(hp.numberOfValidStripTOBHits() == 2); + assert(hp.numberOfValidStripTECHits() == 0); + + assert(hp.numberOfTimingHits() == 0); + assert(hp.numberOfValidTimingHits() == 0); + assert(hp.numberOfValidTimingBTLHits() == 0 ); + assert(hp.numberOfValidTimingETLHits() == 0); + + assert(hp.numberOfLostTimingHits() == 0 ); + assert(hp.numberOfLostTimingBTLHits() == 0); + assert(hp.numberOfLostTimingETLHits() == 0 ); + + assert(hp.numberOfMuonHits() == 0); + assert(hp.numberOfValidMuonHits() == 0); + assert(hp.numberOfValidMuonDTHits() == 0); + assert(hp.numberOfValidMuonCSCHits() == 0); //20 + assert(hp.numberOfValidMuonRPCHits() == 0); + assert(hp.numberOfValidMuonGEMHits() == 0); + assert(hp.numberOfValidMuonME0Hits() == 0); + + assert(hp.numberOfLostMuonHits() == 0); + assert(hp.numberOfLostMuonDTHits() == 0); + assert(hp.numberOfLostMuonCSCHits() == 0); + assert(hp.numberOfLostMuonRPCHits() == 0); + assert(hp.numberOfLostMuonGEMHits() == 0); + assert(hp.numberOfLostMuonME0Hits() == 0); + + assert(hp.numberOfBadHits() == 0); // 30 + assert(hp.numberOfBadMuonHits() == 0); + assert(hp.numberOfBadMuonDTHits() == 0); + assert(hp.numberOfBadMuonCSCHits() == 0); + assert(hp.numberOfBadMuonRPCHits() == 0); + assert(hp.numberOfBadMuonGEMHits() == 0); + assert(hp.numberOfBadMuonME0Hits() == 0); + + assert(hp.numberOfInactiveHits() == 0); + assert(hp.numberOfInactiveTrackerHits() == 0); + //assert(hp.numberOfInactiveTimingHits() ); + + assert(hp.numberOfValidStripLayersWithMonoAndStereo() == 3); + + assert(hp.trackerLayersWithMeasurementOld() == 9); //40 + assert(hp.trackerLayersWithMeasurement() == 9 ); + assert(hp.pixelLayersWithMeasurementOld() == 4); + assert(hp.pixelLayersWithMeasurement() == 4); + assert(hp.stripLayersWithMeasurement() == 5); + assert(hp.pixelBarrelLayersWithMeasurement() == 4); + assert(hp.pixelEndcapLayersWithMeasurement() == 0 ); + assert(hp.stripTIBLayersWithMeasurement() == 4); + assert(hp.stripTIDLayersWithMeasurement() == 0 ); + assert(hp.stripTOBLayersWithMeasurement() == 1); + assert(hp.stripTECLayersWithMeasurement() == 0); //50 + + assert(hp.trackerLayersNull() ==20); + assert(hp.pixelLayersNull() == 3); + assert(hp.stripLayersNull() == 17); + assert(hp.pixelBarrelLayersNull() == 0); + assert(hp.pixelEndcapLayersNull() == 3); + assert(hp.stripTIBLayersNull() == 0); + assert(hp.stripTIDLayersNull() == 3); + assert(hp.stripTOBLayersNull() == 5); + assert(hp.stripTECLayersNull() == 9); + + } HitPattern hp1; diff --git a/DataFormats/TrackingRecHit/src/classes.h b/DataFormats/TrackingRecHit/src/classes.h index c07cc1916be76..8f2141858d77a 100644 --- a/DataFormats/TrackingRecHit/src/classes.h +++ b/DataFormats/TrackingRecHit/src/classes.h @@ -6,23 +6,3 @@ #include "DataFormats/TrackingRecHit/interface/InvalidTrackingRecHit.h" #include "DataFormats/TrackingRecHit/interface/RecSegment.h" #include "DataFormats/Common/interface/Wrapper.h" - -namespace DataFormats_TrackingRecHit { - struct dictionary { - AlgebraicSymMatrix as; - - std::vector v1; - TrackingRecHitCollection c1; - TrackingRecHitRef r1; - InvalidTrackingRecHit i; - TrackingRecHitRefProd rp1; - TrackingRecHitRefVector rv1; - TrackingRecHitRefVector::const_iterator it1; - std::pair >::const_iterator, - edm::OwnVector >::const_iterator> pr1; - std::unique_ptr ap1; - edm::Wrapper w1; - }; -} diff --git a/DataFormats/TrajectorySeed/src/classes.h b/DataFormats/TrajectorySeed/src/classes.h index 8c9c17430210d..22cf0fd8f0776 100644 --- a/DataFormats/TrajectorySeed/src/classes.h +++ b/DataFormats/TrajectorySeed/src/classes.h @@ -8,23 +8,3 @@ #include "DataFormats/Common/interface/Ref.h" #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Common/interface/RefHolder.h" - -namespace DataFormats_TrajectorySeed { - struct dictionary { - std::vector v1; - TrajectorySeedCollection c1; - edm::Wrapper w1; - - edm::RefVectorIterator,TrajectorySeed,edm::refhelper::FindUsingAdvance,TrajectorySeed> > rfitr1; - edm::Ref s1; - edm::RefProd s2; - edm::RefVector s3; - - edm::RefToBase sr; - edm::reftobase::IndirectHolder ihs; - edm::reftobase::Holder< TrajectorySeed, edm::Ref > rbh; - edm::reftobase::RefHolder< edm::Ref > rbrh; - edm::reftobase::RefHolder< edm::Ptr > rhptrts; - edm::Ptr ptrts; - }; -} diff --git a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml index ee790a1a553a4..3edc29e248829 100644 --- a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml +++ b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml @@ -57,7 +57,7 @@ - + diff --git a/DetectorDescription/DDCMS/interface/DDExpandedNode.h b/DetectorDescription/DDCMS/interface/DDExpandedNode.h deleted file mode 100644 index 7ab09663fc8c3..0000000000000 --- a/DetectorDescription/DDCMS/interface/DDExpandedNode.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DETECTOR_DESCRIPTION_DD_EXPANDED_NODE_H -#define DETECTOR_DESCRIPTION_DD_EXPANDED_NODE_H - -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include -#include - -#include - -namespace cms { - - using DDVolume = dd4hep::Volume; - using DDTranslation = ROOT::Math::DisplacementVector3D>; - using DDRotationMatrix = ROOT::Math::Rotation3D; - - struct DDExpandedNode { - - DDVolume volume; // logicalpart to provide access to solid & material information - DDTranslation trans; // absolute translation - DDRotationMatrix rot; // absolute rotation - int copyNo; - int siblingno; // internal sibling-numbering from 0 to max-sibling - DDSpecPar specpar; - - DDExpandedNode(DDVolume const& aVolume, DDTranslation const& aTrans, - DDRotationMatrix const& aRot, int aCopyNo, int num) - : volume(aVolume), - trans(aTrans), - rot(aRot), - copyNo(aCopyNo), - siblingno(num) { - } - }; -} - -#endif diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index 32c8d0c13621d..b6772e49c5034 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -18,36 +18,44 @@ // Created: Wed, 30 Jan 2019 09:24:30 GMT // // -#include "DetectorDescription/DDCMS/interface/DDExpandedNode.h" - +#include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" +#include "DetectorDescription/DDCMS/interface/Filter.h" +#include +#include #include namespace cms { class DDDetector; - //! Geometrical 'path' of the current node up to the root-node - using DDGeoHistory = std::vector; using Volume = dd4hep::Volume; + using PlacedVolume = dd4hep::PlacedVolume; + using ExpandedNodes = cms::ExpandedNodes; + using Filter = cms::Filter; + using Iterator = TGeoIterator; + using Node = TGeoNode; + + class DDFilteredView { + + public: - struct DDFilteredView { - - struct ExpandedNodes { - std::vector tags; - std::vector offsets; - std::vector copyNos; - } nodes; + DDFilteredView(const DDDetector*, const Volume); + DDFilteredView() = delete; - DDFilteredView(const DDDetector*); + //! The numbering history of the current node + const ExpandedNodes& history() const { + return nodes_; + } - //! The logical-part of the current node in the filtered-view - const DDVolume & volume() const; + //! The physical volume of the current node + const PlacedVolume volume() const; //! The absolute translation of the current node - const DDTranslation & translation() const; + const Double_t* trans() const; //! The absolute rotation of the current node - const DDRotationMatrix & rotation() const; + const Double_t* rot() const; //! User specific data void mergedSpecifics(DDSpecParRefs const&); @@ -55,51 +63,49 @@ namespace cms { //! set the current node to the first child bool firstChild(); + //! set the current node to the first sibling + bool firstSibling(); + //! set the current node to the next sibling bool nextSibling(); - //! set current node to the next node in the filtered tree - bool next(); + //! set the current node to the next sub sibling + bool sibling(); + bool siblingNoCheck(); - //! The list of ancestors up to the root-node of the current node - const DDGeoHistory & geoHistory() const; - - bool accepted(std::string_view, std::string_view) const; - bool accepted(std::vector const&, std::string_view) const; - bool acceptedM(std::vector&, std::string_view) const; - std::vector const& topNodes() const { return topNodes_; } - std::vector const& nextNodes() const { return nextNodes_; } - std::vector const& afterNextNodes() const { return afterNextNodes_; } + //! count the number of children matching selection + bool checkChild(); - std::vector extractParameters() const; - std::vector paths(const char*) const; - bool checkPath(std::string_view, TGeoNode *); - bool checkNode(TGeoNode *); + //! set the current node to the parent node ... + bool parent(); + + //! set current node to the next node in the filtered tree + bool next(int); + + //! set current node to the child node in the filtered tree + void down(); + + //! set current node to the parent node in the filtered tree + void up(); + + //! pop current node void unCheckNode(); - void filter(DDSpecParRefs&, std::string_view, std::string_view) const; - std::vector vPathsTo(const DDSpecPar&, unsigned int) const; - std::vector tails(const std::vector& fullPath) const; - DDGeoHistory parents_; - + //! extract shape parameters + std::vector extractParameters() const; + private: - const DDSpecParRegistry* registry_; - bool isRegex(std::string_view) const; - int contains(std::string_view, std::string_view) const; - std::string_view realTopName(std::string_view input) const; - int copyNo(std::string_view input) const; - std::string_view noCopyNo(std::string_view input) const; - std::string_view noNamespace(std::string_view input) const; - std::vector split(std::string_view, const char*) const; - bool acceptRegex(std::string_view, std::string_view) const; + bool accept(std::string_view); + bool addPath(std::string_view, Node* const); + bool addNode(Node* const); - std::vector topNodes_; - std::vector nextNodes_; - std::vector afterNextNodes_; - - TGeoVolume *topVolume_ = nullptr; - TGeoNode *node_ = nullptr; + ExpandedNodes nodes_; + std::vector it_; + std::vector> filters_; + Filter* currentFilter_ = nullptr; + Node *node_ = nullptr; + const DDSpecParRegistry* registry_; }; } diff --git a/DetectorDescription/DDCMS/interface/ExpandedNodes.h b/DetectorDescription/DDCMS/interface/ExpandedNodes.h new file mode 100644 index 0000000000000..59580d16990ec --- /dev/null +++ b/DetectorDescription/DDCMS/interface/ExpandedNodes.h @@ -0,0 +1,33 @@ +#ifndef DETECTOR_DESCRIPTION_EXPANDED_NODES_H +#define DETECTOR_DESCRIPTION_EXPANDED_NODES_H + +// -*- C++ -*- +// +// Package: DetectorDescription/ExpandedNodes +// Class: ExpandedNodes +// +/**\class ExpandedNodes + + Description: ExpandedNodes extra attributes: tags, offsets + and copy numbers + + Implementation: + ExpandedNodes structure to keep the nodes history +*/ +// +// Original Author: Ianna Osborne +// Created: Tue, 18 Mar 2019 12:22:35 CET +// +// +#include + +namespace cms { + + struct ExpandedNodes { + std::vector tags; + std::vector offsets; + std::vector copyNos; + }; +} + +#endif diff --git a/DetectorDescription/DDCMS/interface/Filter.h b/DetectorDescription/DDCMS/interface/Filter.h new file mode 100644 index 0000000000000..f07c720d4d269 --- /dev/null +++ b/DetectorDescription/DDCMS/interface/Filter.h @@ -0,0 +1,45 @@ +#ifndef DETECTOR_DESCRIPTION_FILTER_H +#define DETECTOR_DESCRIPTION_FILTER_H + +// -*- C++ -*- +// +// Package: DetectorDescription/Filter +// Class: Filter +// +/**\class Filter + + Description: Filter list + + Implementation: + Filter criteria is defined in XML +*/ +// +// Original Author: Ianna Osborne +// Created: Tue, 12 Mar 2019 09:51:33 CET +// +// +#include +#include + +namespace cms { + + struct Filter { + std::vector keys; + std::unique_ptr next; + struct Filter* up; + }; + + namespace dd { + bool accepted(std::vector const&, std::string_view); + int contains(std::string_view, std::string_view); + bool isRegex(std::string_view); + bool compareEqual(std::string_view, std::string_view); + std::string_view realTopName(std::string_view input); + std::string_view noCopyNo(std::string_view input); + int copyNo(std::string_view input); + std::string_view noNamespace(std::string_view input); + std::vector split(std::string_view, const char*); + } +} + +#endif diff --git a/DetectorDescription/DDCMS/interface/MuonNumbering.h b/DetectorDescription/DDCMS/interface/MuonNumbering.h index 923c0f4773cc7..c86f6bfd898ed 100644 --- a/DetectorDescription/DDCMS/interface/MuonNumbering.h +++ b/DetectorDescription/DDCMS/interface/MuonNumbering.h @@ -1,7 +1,7 @@ #ifndef DETECTOR_DESCRIPTION_MUON_NUMBERING_H #define DETECTOR_DESCRIPTION_MUON_NUMBERING_H -#include "DetectorDescription/DDCMS/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" #include #include @@ -13,7 +13,7 @@ namespace cms { using MuonConstants = std::unordered_map; struct MuonNumbering { - const MuonBaseNumber geoHistoryToBaseNumber(const DDFilteredView::ExpandedNodes&) const; + const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const; const int get(const char*) const; MuonConstants values; diff --git a/DetectorDescription/DDCMS/python/cmsMFGeometryXML_cfi.py b/DetectorDescription/DDCMS/python/cmsMFGeometryXML_cfi.py index 2ec10f69415bc..9016cda62f751 100644 --- a/DetectorDescription/DDCMS/python/cmsMFGeometryXML_cfi.py +++ b/DetectorDescription/DDCMS/python/cmsMFGeometryXML_cfi.py @@ -3,8 +3,9 @@ XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/normal/cmsextent.xml', 'Geometry/CMSCommonData/data/cms.xml', - 'Geometry/CMSCommonData/data/cmsMagneticField.xml', + 'Geometry/CMSCommonData/data/cmsMagneticField.xml', 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_1.xml', + 'MagneticField/GeomBuilder/data/MagneticFieldVolumes_160812_2.xml', 'Geometry/CMSCommonData/data/materials.xml'), rootNodeName = cms.string('cms:MCMS') ) diff --git a/DetectorDescription/DDCMS/src/DDFilteredView.cc b/DetectorDescription/DDCMS/src/DDFilteredView.cc index 44eaf6bd28d70..ad31b44f8872e 100644 --- a/DetectorDescription/DDCMS/src/DDFilteredView.cc +++ b/DetectorDescription/DDCMS/src/DDFilteredView.cc @@ -3,97 +3,146 @@ #include "DD4hep/Detector.h" #include #include -#include -#include -#include #include using namespace cms; using namespace std; +using namespace cms::dd; -DDFilteredView::DDFilteredView(const DDDetector* det) +DDFilteredView::DDFilteredView(const DDDetector* det, const Volume volume) : registry_(&det->specpars()) { - dd4hep::DetElement world = det->description()->world(); - parents_.emplace_back(DDExpandedNode(world.volume(), DDTranslation(), DDRotationMatrix(), 1, 0)); - topVolume_ = world.volume(); - TGeoIterator next(topVolume_); - next.SetType(0); // 0: DFS; 1: BFS + it_.emplace_back(Iterator(volume)); } -const DDVolume& +const PlacedVolume DDFilteredView::volume() const { - return parents_.back().volume; + return PlacedVolume(node_); } -const DDTranslation& -DDFilteredView::translation() const { - return parents_.back().trans; +const Double_t* +DDFilteredView::trans() const { + return it_.back().GetCurrentMatrix()->GetTranslation(); } -const DDRotationMatrix& -DDFilteredView::rotation() const { - return parents_.back().rot; +const Double_t* +DDFilteredView::rot() const { + return it_.back().GetCurrentMatrix()->GetRotationMatrix(); } void -DDFilteredView::mergedSpecifics(DDSpecParRefs const& refs) { - for(const auto& i : refs) { - auto tops = vPathsTo(*i, 1); - // auto tops = vPathsTo(*i.second, 1); - topNodes_.insert(end(topNodes_), begin(tops), end(tops)); +DDFilteredView::mergedSpecifics(DDSpecParRefs const& specs) { + for(const auto& i : specs) { + for(const auto& j : i->paths) { + vector toks = split(j, "/"); + auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) { + auto const& k = find(begin(f->keys), end(f->keys), toks.front()); + if(k != end(f->keys)) { + currentFilter_ = f.get(); + return true; + } + return false; + }); + if(filter == end(filters_)) { + filters_.emplace_back(unique_ptr(new Filter{{toks.front()}, nullptr, nullptr})); + currentFilter_ = filters_.back().get(); + } + // all next levels + for(size_t pos = 1; pos < toks.size(); ++pos) { + if(currentFilter_->next != nullptr) { + currentFilter_ = currentFilter_->next.get(); + auto const& l = find(begin(currentFilter_->keys), end(currentFilter_->keys), toks[pos]); + if(l == end(currentFilter_->keys)) { + currentFilter_->keys.emplace_back(toks[pos]); + } + } else { + currentFilter_->next.reset(new Filter{{toks[pos]}, nullptr, currentFilter_}); + } + } + } } } bool DDFilteredView::firstChild() { + it_.back().SetType(0); + Node *node = nullptr; + while((node = it_.back().Next())) { + if(accept(noNamespace(node->GetVolume()->GetName()))) { + TString path; + it_.back().GetPath(path); + addPath(path, node); + + return true; + } + } return false; } bool -DDFilteredView::nextSibling() { +DDFilteredView::firstSibling() { + next(0); + it_.emplace_back(Iterator(it_.back())); + it_.back().SetType(1); + if(currentFilter_->next) + currentFilter_ = currentFilter_->next.get(); + else + return false; + do { + if(accepted(currentFilter_->keys, noNamespace(node_->GetVolume()->GetName()))) { + addNode(node_); + return true; + } + } while((node_ = it_.back().Next())); + return false; } bool -DDFilteredView::next() { - return false; -} +DDFilteredView::nextSibling() { + it_.back().SetType(1); + unCheckNode(); + do { + if(accepted(currentFilter_->keys, noNamespace(node_->GetVolume()->GetName()))) { + addNode(node_); + return true; + } + } while((node_ = it_.back().Next())); -const DDGeoHistory& -DDFilteredView::geoHistory() const { - return parents_; + return false; } bool -DDFilteredView::acceptRegex(string_view name, string_view node) const { - if(!isRegex(name) && !isRegex(node)) { - return (name == node); - } else { - if(isRegex(name)) { - regex pattern({name.data(), name.size()}); - return regex_search(begin(node), end(node), pattern); - } else if(isRegex(node)) { - regex pattern({node.data(), node.size()}); - return regex_search(begin(name), end(name), pattern); +DDFilteredView::sibling() { + it_.back().SetType(1); + Node *node = nullptr; + while((node = it_.back().Next())) { + if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + addNode(node); + return true; } } return false; } bool -DDFilteredView::accepted(string_view name, string_view node) const { - if(!isRegex(name)) { - return (name == node); - } else { - regex pattern({name.data(), name.size()}); - return regex_search(begin(node), end(node), pattern); +DDFilteredView::siblingNoCheck() { + it_.back().SetType(1); + Node *node = nullptr; + while((node = it_.back().Next())) { + if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { + node_ = node; + return true; + } } + return false; } bool -DDFilteredView::accepted(vector const& names, string_view node) const { - for(auto const& i : names) { - if(accepted(i, node)) { +DDFilteredView::checkChild() { + it_.back().SetType(1); + Node *node = nullptr; + while((node = it_.back().Next())) { + if(accepted(currentFilter_->keys, noNamespace(node->GetVolume()->GetName()))) { return true; } } @@ -101,46 +150,51 @@ DDFilteredView::accepted(vector const& names, string_view node) con } bool -DDFilteredView::acceptedM(vector& names, string_view node) const { - auto itr = find_if(names.begin(), names.end(), [ & ]( const auto& i){ return accepted(i, node); }); - if(itr != names.end() && (!isRegex(*itr))) { - names.erase(itr); - return true; - } - return false; +DDFilteredView::parent() { + up(); + it_.back().SetType(0); + it_.back().Skip(); + + return true; } -string_view -DDFilteredView::realTopName(string_view input) const { - string_view v = input; - auto first = v.find_first_of("//"); - v.remove_prefix(min(first+2, v.size())); - return v; +bool +DDFilteredView::next(int type) { + it_.back().SetType(type); + Node *node = nullptr; + if((node = it_.back().Next())) { + node_ = node; + return true; + } + else + return false; } -string_view -DDFilteredView::noNamespace(string_view input) const { - string_view v = input; - auto first = v.find_first_of(":"); - v.remove_prefix(min(first+1, v.size())); - return v; +void +DDFilteredView::down() { + it_.emplace_back(Iterator(it_.back())); + next(0); + if(currentFilter_->next) + currentFilter_ = currentFilter_->next.get(); } -string_view -DDFilteredView::noCopyNo(string_view input) const { - string_view v = input; - auto last = v.find_last_of("_"); - v.remove_suffix(v.size() - min(last, v.size())); - return v; +void +DDFilteredView::up() { + it_.pop_back(); + if(currentFilter_->up) + currentFilter_ = currentFilter_->up; } -int -DDFilteredView::copyNo(string_view input) const { - string_view v = input; - auto last = v.find_last_of("_"); - v.remove_prefix(min(last+1, v.size())); - - return stoi({v.data(), v.size()}); +bool +DDFilteredView::accept(std::string_view name) { + bool result = false; + for(const auto& it : filters_) { + currentFilter_ = it.get(); + result = accepted(currentFilter_->keys, name); + if(result) + return result; + } + return result; } vector @@ -163,28 +217,12 @@ DDFilteredView::extractParameters() const { } bool -DDFilteredView::isRegex(string_view input) const { - return ((contains(input, "*") != -1) || - (contains(input, ".") != -1)); -} - -int -DDFilteredView::contains(string_view input, string_view needle) const { - auto const& it = search(begin(input), end(input), - boyer_moore_searcher(begin(needle), end(needle))); - if(it != end(input)) { - return (it - begin(input)); - } - return -1; -} - -bool -DDFilteredView::checkPath(string_view path, TGeoNode *node) { +DDFilteredView::addPath(string_view path, Node* const node) { assert(registry_); node_ = node; - nodes.tags.clear(); - nodes.offsets.clear(); - nodes.copyNos.clear(); + nodes_.tags.clear(); + nodes_.offsets.clear(); + nodes_.copyNos.clear(); bool result(false); auto v = split(path, "/"); @@ -194,14 +232,14 @@ DDFilteredView::checkPath(string_view path, TGeoNode *node) { for(auto const& rv : v) { for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) { auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) { - return (acceptRegex(noCopyNo(rv), *begin(split(realTopName(j), "/"))) && + return (compareEqual(noCopyNo(rv), *begin(split(realTopName(j), "/"))) && (i.second.hasValue("CopyNoTag") || i.second.hasValue("CopyNoOffset"))); }); if(k != end(i.second.paths)) { - nodes.tags.emplace_back(i.second.dblValue("CopyNoTag")); - nodes.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); - nodes.copyNos.emplace_back(copyNo(rv)); + nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag")); + nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); + nodes_.copyNos.emplace_back(copyNo(rv)); result = true; } }); @@ -210,20 +248,20 @@ DDFilteredView::checkPath(string_view path, TGeoNode *node) { } bool -DDFilteredView::checkNode(TGeoNode *node) { +DDFilteredView::addNode(Node* const node) { assert(registry_); node_ = node; bool result(false); for_each(begin(registry_->specpars), end(registry_->specpars), [&](auto const& i) { auto k = find_if(begin(i.second.paths), end(i.second.paths),[&](auto const& j) { - return (acceptRegex(noCopyNo(noNamespace(node_->GetName())), *begin(split(realTopName(j), "/"))) && + return (compareEqual(noCopyNo(noNamespace(node_->GetName())), *begin(split(realTopName(j), "/"))) && (i.second.hasValue("CopyNoTag") || i.second.hasValue("CopyNoOffset"))); }); if(k != end(i.second.paths)) { - nodes.tags.emplace_back(i.second.dblValue("CopyNoTag")); - nodes.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); - nodes.copyNos.emplace_back(copyNo(node_->GetName())); + nodes_.tags.emplace_back(i.second.dblValue("CopyNoTag")); + nodes_.offsets.emplace_back(i.second.dblValue("CopyNoOffset")); + nodes_.copyNos.emplace_back(copyNo(node_->GetName())); result = true; } }); @@ -232,48 +270,7 @@ DDFilteredView::checkNode(TGeoNode *node) { void DDFilteredView::unCheckNode() { - nodes.tags.pop_back(); - nodes.offsets.pop_back(); - nodes.copyNos.pop_back(); -} - -vector -DDFilteredView::split(string_view str, const char* delims) const { - vector ret; - - string_view::size_type start = 0; - auto pos = str.find_first_of(delims, start); - while(pos != string_view::npos) { - if(pos != start) { - ret.emplace_back(str.substr(start, pos - start)); - } - start = pos + 1; - pos = str.find_first_of(delims, start); - } - if(start < str.length()) - ret.emplace_back(str.substr(start, str.length() - start)); - return ret; -} - -vector -DDFilteredView::vPathsTo(const DDSpecPar& specpar, unsigned int level) const { - vector result; - for(auto const& i : specpar.paths) { - vector toks = split(i, "/"); - if(level == toks.size()) - result.emplace_back(realTopName(i)); - } - return result; -} - -vector -DDFilteredView::tails(const vector& fullPath) const { - vector result; - for(auto const& v : fullPath) { - auto found = v.find_last_of("/"); - if(found != v.npos) { - result.emplace_back(v.substr(found + 1)); - } - } - return result; + nodes_.tags.pop_back(); + nodes_.offsets.pop_back(); + nodes_.copyNos.pop_back(); } diff --git a/DetectorDescription/DDCMS/src/Filter.cc b/DetectorDescription/DDCMS/src/Filter.cc new file mode 100644 index 0000000000000..f237c066a5d43 --- /dev/null +++ b/DetectorDescription/DDCMS/src/Filter.cc @@ -0,0 +1,87 @@ +#include "DetectorDescription/DDCMS/interface/Filter.h" +#include +#include +#include + +using namespace std; + +namespace cms { + namespace dd { + + bool compareEqual(string_view node, string_view name) { + if(!isRegex(name)) { + return (name == node); + } else { + regex pattern({name.data(), name.size()}); + return regex_match(begin(node), end(node), pattern); + } + } + + bool accepted(vector const& names, string_view node) { + return (find_if(begin(names), end(names), + [&](const auto& n) -> bool { return compareEqual(node, n); }) + != end(names)); + } + + int contains(string_view input, string_view needle) { + auto const& it = search(begin(input), end(input), + default_searcher(begin(needle), end(needle))); + if(it != end(input)) { + return (it - begin(input)); + } + return -1; + } + + bool isRegex(string_view input) { + return ((contains(input, "*") != -1) || + (contains(input, ".") != -1)); + } + + string_view realTopName(string_view input) { + string_view v = input; + auto first = v.find_first_of("//"); + v.remove_prefix(min(first+2, v.size())); + return v; + } + + string_view noCopyNo(string_view input) { + string_view v = input; + auto last = v.find_last_of("_"); + v.remove_suffix(v.size() - min(last, v.size())); + return v; + } + + int copyNo(string_view input) { + string_view v = input; + auto last = v.find_last_of("_"); + v.remove_prefix(min(last+1, v.size())); + + return stoi({v.data(), v.size()}); + } + + string_view noNamespace(string_view input) { + string_view v = input; + auto first = v.find_first_of(":"); + v.remove_prefix(min(first+1, v.size())); + return v; + } + + vector + split(string_view str, const char* delims) { + vector ret; + + string_view::size_type start = 0; + auto pos = str.find_first_of(delims, start); + while(pos != string_view::npos) { + if(pos != start) { + ret.emplace_back(str.substr(start, pos - start)); + } + start = pos + 1; + pos = str.find_first_of(delims, start); + } + if(start < str.length()) + ret.emplace_back(str.substr(start, str.length() - start)); + return ret; + } + } +} diff --git a/DetectorDescription/DDCMS/src/MuonNumbering.cc b/DetectorDescription/DDCMS/src/MuonNumbering.cc index 1bda339c3eea5..bdbbc39d9a4a0 100644 --- a/DetectorDescription/DDCMS/src/MuonNumbering.cc +++ b/DetectorDescription/DDCMS/src/MuonNumbering.cc @@ -9,7 +9,7 @@ using namespace std; using namespace edm; const MuonBaseNumber -MuonNumbering::geoHistoryToBaseNumber(const DDFilteredView::ExpandedNodes &nodes) const { +MuonNumbering::geoHistoryToBaseNumber(const cms::ExpandedNodes &nodes) const { MuonBaseNumber num; int levelPart = get("level"); diff --git a/DetectorDescription/DDCMS/test/BuildFile.xml b/DetectorDescription/DDCMS/test/BuildFile.xml index 39115623289e2..d56021563ca5f 100644 --- a/DetectorDescription/DDCMS/test/BuildFile.xml +++ b/DetectorDescription/DDCMS/test/BuildFile.xml @@ -1,4 +1,14 @@ + + + + + + + + + + diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc new file mode 100644 index 0000000000000..b4ea649e29b26 --- /dev/null +++ b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc @@ -0,0 +1,44 @@ +#include + +#include "DetectorDescription/DDCMS/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/DDDetector.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "DD4hep/Detector.h" + +#include +#include + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" + +using namespace cms; +using namespace std; + +class testDDFilteredView : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testDDFilteredView); + CPPUNIT_TEST(checkFilteredView); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() override; + void tearDown() override {} + void checkFilteredView(); + +private: + + string fileName_; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(testDDFilteredView); + +void testDDFilteredView::setUp() { + fileName_ = edm::FileInPath("DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml").fullPath(); +} + +void testDDFilteredView::checkFilteredView() +{ +unique_ptr det = make_unique("DUMMY", fileName_); + DDFilteredView fview(det.get(), det->description()->worldVolume()); +} diff --git a/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc b/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc new file mode 100644 index 0000000000000..0948e9deea2dc --- /dev/null +++ b/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc @@ -0,0 +1,46 @@ +#include + +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" + +#include + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" + +using namespace cms; +using namespace std; + +class testExpandedNodes : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testExpandedNodes); + CPPUNIT_TEST(checkExpandedNodes); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() override; + void tearDown() override {} + void checkExpandedNodes(); + +private: + ExpandedNodes nodes_; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(testExpandedNodes); + +void +testExpandedNodes::setUp() { + nodes_.tags = { 1., 2., 3. }; + nodes_.offsets = { 1., 2., 3. }; + nodes_.copyNos = { 1, 2, 3 }; +} + +void +testExpandedNodes::checkExpandedNodes() { + cout << "Expanded Nodes...\n"; + CPPUNIT_ASSERT(nodes_.tags.size() == nodes_.offsets.size()); + CPPUNIT_ASSERT(nodes_.tags.size() == nodes_.copyNos.size()); + + for(auto const& i : nodes_.tags) + cout << i << " "; +} diff --git a/DetectorDescription/DDCMS/test/Filter.cppunit.cc b/DetectorDescription/DDCMS/test/Filter.cppunit.cc new file mode 100644 index 0000000000000..01a803b4c8ef9 --- /dev/null +++ b/DetectorDescription/DDCMS/test/Filter.cppunit.cc @@ -0,0 +1,103 @@ +#include + +#include "DetectorDescription/DDCMS/interface/Filter.h" +#include +#include +#include + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" + +using namespace cms; +using namespace cms::dd; +using namespace std; +using namespace std::literals; + +class testFilter : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testFilter); + CPPUNIT_TEST(checkFilter); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() override; + void tearDown() override {} + void checkFilter(); + +private: + void print(Filter*); + vector> filters_; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(testFilter); + +void +testFilter::setUp() +{ + vector selections = {"//MB2P.*", + "//MB2P.*/MB2SuperLayerPhi", + "//MB2P.*/MB2SuperLayerPhi/MB2SLPhiLayer_.*Cells.*", + "//MB2P.*/MB2SuperLayerPhi/MB2SLPhiLayer_.*Cells.*/MBSLPhiGas", + "//MB2P.*/MB2SuperLayerZ", + "//MB2P.*/MB2SuperLayerZ/MB2SLZLayer_.*Cells", + "//MB2P.*/MB2SuperLayerZ/MB2SLZLayer_.*Cells/MB2SLZGas"}; + Filter* currentFilter = nullptr; + + for(const auto& i : selections) { + vector toks = split(i, "/"); + unique_ptr f = nullptr; + auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) { + auto const& k = find(begin(f->keys), end(f->keys), toks.front()); + if(k != end(f->keys)) { + currentFilter = f.get(); + return true; + } + return false; + }); + if(filter == end(filters_)) { + filters_.emplace_back(unique_ptr(new Filter{{toks.front()}, nullptr, nullptr})); + currentFilter = filters_.back().get(); + } + // all next levels + for(size_t pos = 1; pos < toks.size(); ++pos) { + if(currentFilter->next != nullptr) { + currentFilter = currentFilter->next.get(); + auto const& l = find(begin(currentFilter->keys), end(currentFilter->keys), toks[pos]); + if(l == end(currentFilter->keys)) { + currentFilter->keys.emplace_back(toks[pos]); + } + } else { + currentFilter->next.reset(new Filter{{toks[pos]}, nullptr, currentFilter}); + } + } + } +} + +void +testFilter::checkFilter() +{ + string_view name = "MB2P.*"sv; + CPPUNIT_ASSERT(filters_.front()->keys.front() == name); + CPPUNIT_ASSERT(filters_.front()->up == nullptr); + CPPUNIT_ASSERT(filters_.front()->next != nullptr); + CPPUNIT_ASSERT(filters_.size() == 1); + + Filter* current = nullptr; + cout << "Filters...\n"; + for(auto const& i : filters_) { + current = i.get(); + do { + print(current); + current = current->next.get(); + } while(current != nullptr); + } +} + +void +testFilter::print(Filter* filter) { + for(auto const& it : filter->keys) { + cout << it << " "; + } + cout << "\n"; +} diff --git a/DetectorDescription/Parser/test/BuildFile.xml b/DetectorDescription/Parser/test/BuildFile.xml index dffbfe339456e..559eed7f33e8a 100644 --- a/DetectorDescription/Parser/test/BuildFile.xml +++ b/DetectorDescription/Parser/test/BuildFile.xml @@ -6,9 +6,8 @@ - + - diff --git a/DetectorDescription/Parser/test/testmat.cpp b/DetectorDescription/Parser/test/testmat.cpp index 1943eadc63f89..7708a0d296649 100644 --- a/DetectorDescription/Parser/test/testmat.cpp +++ b/DetectorDescription/Parser/test/testmat.cpp @@ -7,6 +7,7 @@ #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Parser/interface/DDLElementRegistry.h" #include "DetectorDescription/Parser/src/DDLElementaryMaterial.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/PluginManager/interface/PresenceFactory.h" #include "FWCore/PluginManager/interface/ProblemTracker.h" #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" @@ -55,7 +56,10 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); + // E. Make the services available. diff --git a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h index e39e4ea9f79aa..b82d354a97541 100644 --- a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h +++ b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h @@ -4,8 +4,6 @@ #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h" #include "DataFormats/GeometrySurface/interface/Plane.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include -#include namespace dd4hep { class Detector; @@ -19,7 +17,7 @@ class DTLayer; namespace cms { class DDDetector; - struct DDFilteredView; + class DDFilteredView; struct MuonNumbering; struct DDSpecPar; @@ -29,9 +27,6 @@ namespace cms { ~DTGeometryBuilder() {} using Detector = dd4hep::Detector; - using DDRotationMatrix = ROOT::Math::Rotation3D; - using DDTranslation = ROOT::Math::DisplacementVector3D>; - using DD3Vector = ROOT::Math::DisplacementVector3D>; using DDSpecParRefs = std::vector; void build(DTGeometry&, @@ -40,33 +35,25 @@ namespace cms { const DDSpecParRefs&); private: void buildGeometry(DDFilteredView&, - const DDSpecPar&, DTGeometry&, const MuonNumbering&) const; /// create the chamber DTChamber* buildChamber(const DDFilteredView&, - const DDTranslation&, - const DDRotationMatrix&, const MuonNumbering&) const; /// create the SL DTSuperLayer* buildSuperLayer(const DDFilteredView&, DTChamber*, - const DDTranslation&, - const DDRotationMatrix&, const MuonNumbering&) const; /// create the layer - DTLayer* buildLayer(const DDFilteredView&, + DTLayer* buildLayer(DDFilteredView&, DTSuperLayer*, - const DDTranslation&, - const DDRotationMatrix&, const MuonNumbering&) const; using RCPPlane = ReferenceCountingPointer; - RCPPlane plane(const DDTranslation&, - const DDRotationMatrix&, + RCPPlane plane(const DDFilteredView&, Bounds* bounds) const; }; } diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc b/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc index 8d369238512be..fb1d21590ed75 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc +++ b/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc @@ -73,6 +73,26 @@ DTGeometryTest::analyze(const Event&, const EventSetup& iEventSetup) } }); LogVerbatim("Geometry") << "END " << string(120, '-'); + + // check layers + LogVerbatim("Geometry") << "LAYERS " << string(120, '-'); + + LogVerbatim("Geometry").log([&](auto& log) { + for(auto det : pDD->layers()){ + const DTTopology& topo = det->specificTopology(); + const BoundPlane& surf=det->surface(); + log << "Layer " << det->id() << " SL " << det->superLayer()->id() + << " chamber " << det->chamber()->id() + << " Topology W/H/L: " + << topo.cellWidth() << "/" << topo.cellHeight() << "/" << topo.cellLenght() + << " first/last/# wire " << topo.firstChannel() << "/" << topo.lastChannel() << "/" << topo.channels() + << " Position " << surf.position() + << " normVect " << surf.normalVector() + << " bounds W/H/L: " << surf.bounds().width() << "/" + << surf.bounds().thickness() << "/" << surf.bounds().length() << "\n"; + } + }); + LogVerbatim("Geometry") << "END " << string(120, '-'); } DEFINE_FWK_MODULE(DTGeometryTest); diff --git a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc b/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc index 5de7cddf33f4b..c3417d3797001 100644 --- a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc +++ b/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc @@ -55,149 +55,71 @@ using namespace edm; using namespace std; using namespace cms; -namespace { - - string_view noNamespace(string_view input) { - string_view v = input; - auto first = v.find_first_of(":"); - v.remove_prefix(min(first+1, v.size())); - return v; - } -} - void DTGeometryBuilder::buildGeometry(DDFilteredView& fview, - const DDSpecPar& specpar, DTGeometry& geom, const MuonNumbering& num) const { - TGeoVolume *topVolume = fview.geoHistory().back().volume; - TGeoIterator next(topVolume); - next.SetType(0); // 0: DFS; 1: BFS - TGeoNode *node; - - //find all Chamber nodes - auto const& chamberSelection = fview.vPathsTo(specpar, 1); - - //find all Super Layer nodes - auto const& superLayerSelection = fview.tails(fview.vPathsTo(specpar, 2)); - - //find all Layer nodes - auto const& layerSelection = fview.tails(fview.vPathsTo(specpar, 3)); - - // Not used: - // auto const& type = specpar.strValue("Type"); - // auto const& FEPos = specpar.strValue("FEPos"); + + bool doChamber = fview.firstChild(); - while((node = next())) { - // If the node matches the Chamber selection - if(fview.accepted(chamberSelection, noNamespace(node->GetVolume()->GetName()))) { - // The matrix is absolute - const TGeoMatrix *matrix = next.GetCurrentMatrix(); - const Double_t *rot = matrix->GetRotationMatrix(); - const Double_t *tr = matrix->GetTranslation(); - - // FIXME: Create an ExpanedNode here - int nd = node->GetNdaughters(); - TString path; - next.GetPath(path); - fview.checkPath(path, node); + while(doChamber) { + DTChamber* chamber = buildChamber(fview, num); + + // Loop on SLs + bool doSL = fview.firstSibling(); + while(doSL) { + DTSuperLayer* sl = buildSuperLayer(fview, chamber, num); - DDTranslation chTr = DDTranslation(tr[0], tr[1], tr[2]); - DDRotationMatrix chRot = DDRotationMatrix(rot[0], rot[1], rot[2], - rot[3], rot[4], rot[5], - rot[6], rot[7], rot[8]); - DTChamber* chamber = buildChamber(fview, - chTr, chRot, - num); - // Loop on SLs - TGeoNode *currentSLayer = nullptr; - - for(int i = 0; i < nd; ++i) { - currentSLayer = static_cast(node->GetNodes()->At(i)); - - if(fview.accepted(superLayerSelection, noNamespace(currentSLayer->GetVolume()->GetName()))) { - // The matrix is relative - const TGeoMatrix *slMatrix = currentSLayer->GetMatrix(); - const Double_t *slrot = slMatrix->GetRotationMatrix(); - const Double_t *sltr = slMatrix->GetTranslation(); - // This matrix is absolute - DDTranslation slTr = chTr + (chRot * DDTranslation(sltr[0], sltr[1], sltr[2])); - DDRotationMatrix slRot = chRot * DDRotationMatrix(slrot[0], slrot[1], slrot[2], - slrot[3], slrot[4], slrot[5], - slrot[6], slrot[7], slrot[8]); - - fview.checkNode(currentSLayer); - - DTSuperLayer* sl = buildSuperLayer(fview, chamber, - slTr, slRot, - num); - // Loop on Layers - TGeoNode *currentLayer = nullptr; - int ndLs = currentSLayer->GetNdaughters(); - for(int j = 0; j < ndLs; ++j) { - currentLayer = static_cast(currentSLayer->GetNodes()->At(j)); - if(fview.accepted(layerSelection, noNamespace(currentLayer->GetVolume()->GetName()))) { - // The matrix is relative - const TGeoMatrix *lMatrix = currentLayer->GetMatrix(); - const Double_t *lrot = lMatrix->GetRotationMatrix(); - const Double_t *ltr = lMatrix->GetTranslation(); + // Loop on Layers + fview.down(); + bool doLayers = fview.sibling(); + while(doLayers) { + DTLayer* l = buildLayer(fview, sl, num); + fview.unCheckNode(); + geom.add(l); - // This matrix is absolute - DDTranslation lTr = slTr + (slRot * DDTranslation(ltr[0], ltr[1], ltr[2])); - DDRotationMatrix lRot = slRot * DDRotationMatrix(lrot[0], lrot[1], lrot[2], - lrot[3], lrot[4], lrot[5], - lrot[6], lrot[7], lrot[8]); - - fview.checkNode(currentLayer); - - DTLayer* l = buildLayer(fview, sl, - lTr, lRot, - num); - fview.unCheckNode(); - geom.add(l); - } - } - fview.unCheckNode(); - geom.add(sl); - } + doLayers = fview.sibling(); // go to next Layer } - geom.add(chamber); + // Done with layers, go up + fview.up(); + + geom.add(sl); + doSL = fview.nextSibling(); // go to next SL } + geom.add(chamber); + + fview.parent(); // stop iterating current branch + doChamber = fview.firstChild(); // go to next chamber } } DTGeometryBuilder::RCPPlane -DTGeometryBuilder::plane(const DDTranslation& trans, - const DDRotationMatrix& rotation, +DTGeometryBuilder::plane(const DDFilteredView& fview, Bounds* bounds) const { - const Surface::PositionType posResult(trans.x(), - trans.y(), - trans.z()); - DD3Vector x, y, z; - rotation.GetComponents(x,y,z); - - Surface::RotationType rotResult(x.X(), x.Y(), x.Z(), - y.X(), y.Y(), y.Z(), - z.X(), z.Y(), z.Z()); + const Double_t *tr = fview.trans(); + const Double_t *rot = fview.rot(); - return RCPPlane(new Plane(posResult, rotResult, bounds)); + return RCPPlane(new Plane(Surface::PositionType(tr[0], tr[1], tr[2]), + Surface::RotationType(rot[0], rot[3], rot[6], + rot[1], rot[4], rot[7], + rot[2], rot[5], rot[8]), + bounds)); } DTChamber* DTGeometryBuilder::buildChamber(const DDFilteredView& fview, - const DDTranslation& trans, - const DDRotationMatrix& rotation, const MuonNumbering& muonConstants) const { MuonConstants cons = muonConstants.values; DTNumberingScheme dtnum(cons); - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.nodes)); + int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTChamberId detId(rawid); auto const& par = fview.extractParameters(); // par[0] r-phi dimension - different in different chambers // par[1] z dimension - constant 125.55 cm // par[2] radial thickness - almost constant about 18 cm - RCPPlane surf(plane(trans, rotation, new RectangularPlaneBounds(par[0], par[1], par[2]))); + + RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2]))); DTChamber* chamber = new DTChamber(detId, surf); @@ -207,13 +129,11 @@ DTGeometryBuilder::buildChamber(const DDFilteredView& fview, DTSuperLayer* DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview, DTChamber* chamber, - const DDTranslation& trans, - const DDRotationMatrix& rotation, const MuonNumbering& muonConstants) const { MuonConstants cons = muonConstants.values; DTNumberingScheme dtnum(cons); - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.nodes)); + int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTSuperLayerId slId(rawid); auto const& par = fview.extractParameters(); @@ -222,7 +142,7 @@ DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview, // par[2] radial thickness - almost constant about 20 cm // Ok this is the slayer position... - RCPPlane surf(plane(trans, rotation, new RectangularPlaneBounds(par[0], par[1], par[2]))); + RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2]))); DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber); @@ -233,15 +153,13 @@ DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview, } DTLayer* -DTGeometryBuilder::buildLayer(const DDFilteredView& fview, +DTGeometryBuilder::buildLayer(DDFilteredView& fview, DTSuperLayer* sl, - const DDTranslation& trans, - const DDRotationMatrix& rotation, const MuonNumbering& muonConstants) const { MuonConstants cons = muonConstants.values; DTNumberingScheme dtnum(cons); - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.nodes)); + int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTLayerId layId(rawid); auto const& par = fview.extractParameters(); @@ -249,25 +167,28 @@ DTGeometryBuilder::buildLayer(const DDFilteredView& fview, // par[0] r-phi dimension - changes in different chambers // par[1] z dimension - constant 126.8 cm // par[2] radial thickness - almost constant about 20 cm - RCPPlane surf(plane(trans, rotation, new RectangularPlaneBounds(par[0], par[1], par[2]))); + RCPPlane surf(plane(fview, new RectangularPlaneBounds(par[0], par[1], par[2]))); + + // Loop on wires + fview.down(); + bool doWire = fview.siblingNoCheck(); + int firstWire = fview.volume()->GetNumber(); // copy no + auto const& wpar = fview.extractParameters(); + float wireLength = wpar[1]; - // FIXME: // Loop on wires - // bool doWire = fv.firstChild(); int WCounter = 0; - int firstWire = 1; //FIXME: copyno; - // par = extractParameters(fv); - float wireLength = par[1]; - // while (doWire) { - // WCounter++; - // doWire = fv.nextSibling(); // next wire - // } - // //int lastWire=fv.copyno(); + while(doWire) { + doWire = fview.checkChild(); + WCounter++; + } + fview.up(); + DTTopology topology(firstWire, WCounter, wireLength); DTLayerType layerType; DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl); - + sl->add(layer); return layer; } @@ -277,9 +198,9 @@ DTGeometryBuilder::build(DTGeometry& geom, const cms::DDDetector* det, const MuonNumbering& num, const DDSpecParRefs& refs) { - DDFilteredView fview(det); - for(const auto& i: refs) { - buildGeometry(fview, *i, geom, num); - } + dd4hep::DetElement world = det->description()->world(); + DDFilteredView fview(det, world.volume()); + fview.mergedSpecifics(refs); + buildGeometry(fview, geom, num); } diff --git a/DetectorDescription/RegressionTest/test/BuildFile.xml b/DetectorDescription/RegressionTest/test/BuildFile.xml index bd4bb84cbc9f3..5f1cb50b3a3c7 100644 --- a/DetectorDescription/RegressionTest/test/BuildFile.xml +++ b/DetectorDescription/RegressionTest/test/BuildFile.xml @@ -3,9 +3,8 @@ - + - @@ -14,9 +13,8 @@ - + - @@ -26,9 +24,8 @@ - + - @@ -42,9 +39,8 @@ - + - @@ -129,8 +125,6 @@ - - diff --git a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp index 6216f0a364699..391b743c0821f 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDCompactView.cpp @@ -13,6 +13,7 @@ #include "DetectorDescription/Core/src/Material.h" #include "DetectorDescription/Parser/interface/DDLParser.h" #include "DetectorDescription/Parser/interface/FIPConfiguration.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/PluginManager/interface/PresenceFactory.h" #include "FWCore/PluginManager/interface/ProblemTracker.h" #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" @@ -63,7 +64,10 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); + // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp index 3c75786a062e8..164da26057aa2 100644 --- a/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp +++ b/DetectorDescription/RegressionTest/test/dumpDDExpandedView.cpp @@ -10,6 +10,7 @@ #include "DetectorDescription/Core/src/Material.h" #include "DetectorDescription/Parser/interface/DDLParser.h" #include "DetectorDescription/Parser/interface/FIPConfiguration.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/PluginManager/interface/PresenceFactory.h" #include "FWCore/PluginManager/interface/ProblemTracker.h" #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" @@ -59,7 +60,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp index 050f8f4abdb5b..86dad772c3e45 100644 --- a/DetectorDescription/RegressionTest/test/testDDCompactView.cpp +++ b/DetectorDescription/RegressionTest/test/testDDCompactView.cpp @@ -11,6 +11,7 @@ #include "DetectorDescription/RegressionTest/src/DDCheck.h" #include "DetectorDescription/Parser/interface/DDLParser.h" #include "DetectorDescription/Parser/interface/FIPConfiguration.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/PluginManager/interface/PresenceFactory.h" #include "FWCore/PluginManager/interface/ProblemTracker.h" #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" @@ -59,7 +60,9 @@ int main(int argc, char *argv[]) "process.e = cms.EndPath(process.out)\n"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h b/EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h index 637993341179b..69f2d4501269f 100644 --- a/EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h +++ b/EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h @@ -6,7 +6,6 @@ #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/PatCandidates/interface/Electron.h" -#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" @@ -79,7 +78,6 @@ class SuperClusterHelper { const EcalRecHitCollection * rechits_; const CaloTopology* topology_; const CaloGeometry* geometry_; - EcalClusterLocal local_; bool barrel_; diff --git a/EgammaAnalysis/ElectronTools/src/SuperClusterHelper.cc b/EgammaAnalysis/ElectronTools/src/SuperClusterHelper.cc index ad9c347ccd048..45767df901487 100644 --- a/EgammaAnalysis/ElectronTools/src/SuperClusterHelper.cc +++ b/EgammaAnalysis/ElectronTools/src/SuperClusterHelper.cc @@ -1,6 +1,7 @@ #include "EgammaAnalysis/ElectronTools/interface/SuperClusterHelper.h" #include "Geometry/CaloTopology/interface/CaloTopology.h" #include "FWCore/Utilities/interface/isFinite.h" +#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" @@ -129,9 +130,9 @@ void SuperClusterHelper::localCoordinates() { if (localCoordinatesComputed_) return; if (barrel_) { - local_.localCoordsEB(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_); + egammaTools::localEcalClusterCoordsEB(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_); } else { - local_.localCoordsEE(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_); + egammaTools::localEcalClusterCoordsEE(*seedCluster_, *geometry_, etaCrySeed_ , phiCrySeed_ ,ietaSeed_ , iphiSeed_ , thetaTilt_ , phiTilt_); } localCoordinatesComputed_ = true; } diff --git a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc index 24fafba4f2ce5..3ae6e21d24e06 100644 --- a/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc +++ b/EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc @@ -38,7 +38,6 @@ #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" @@ -47,6 +46,7 @@ #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "TrackingTools/IPTools/interface/IPTools.h" #include "FWCore/Utilities/interface/isFinite.h" +#include "DataFormats/Math/interface/normalizedPhi.h" #include #include @@ -357,7 +357,7 @@ ElectronTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& i float etareco = theEGamma[j].eta(); float phireco = theEGamma[j].phi(); float deta = etamc - etareco; - float dphi = Utils::mpi_pi(phimc - phireco); + float dphi = normalizedPhi(phimc - phireco); float dR = sqrt(deta*deta + dphi*dphi); diff --git a/ElectroWeakAnalysis/ZEE/src/ZeeCandidateFilter.cc b/ElectroWeakAnalysis/ZEE/src/ZeeCandidateFilter.cc index d1ab654ba41ea..44666a525abfb 100644 --- a/ElectroWeakAnalysis/ZEE/src/ZeeCandidateFilter.cc +++ b/ElectroWeakAnalysis/ZEE/src/ZeeCandidateFilter.cc @@ -932,11 +932,10 @@ Bool_t ZeeCandidateFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSe if ( iEvent.getByToken(tracksToken_, ctfTracks) ) { - ConversionFinder convFinder; - ConversionInfo convInfo = convFinder.getConversionInfo(maxETelec1, ctfTracks, bfield); + ConversionInfo convInfo = egammaTools::getConversionInfo(maxETelec1, ctfTracks, bfield); - Float_t dist = convInfo.dist(); - Float_t dcot = convInfo.dcot(); + Float_t dist = convInfo.dist; + Float_t dcot = convInfo.dcot; Bool_t isConv = ( ( TMath::Abs(dist) < dist1_ ) && ( TMath::Abs(dcot) < dcot1_ ) ) ; @@ -1003,11 +1002,10 @@ Bool_t ZeeCandidateFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSe if ( iEvent.getByToken(tracksToken_, ctfTracks) ) { - ConversionFinder convFinder; - ConversionInfo convInfo = convFinder.getConversionInfo(maxETelec2, ctfTracks, bfield); + ConversionInfo convInfo = egammaTools::getConversionInfo(maxETelec2, ctfTracks, bfield); - Float_t dist = convInfo.dist(); - Float_t dcot = convInfo.dcot(); + Float_t dist = convInfo.dist; + Float_t dcot = convInfo.dcot; Bool_t isConv = ( ( TMath::Abs(dist) < dist2_ ) && ( TMath::Abs(dcot) < dcot2_ ) ) ; diff --git a/EventFilter/GEMRawToDigi/BuildFile.xml b/EventFilter/GEMRawToDigi/BuildFile.xml index adb5e7ade841f..bb98fdbe7708a 100644 --- a/EventFilter/GEMRawToDigi/BuildFile.xml +++ b/EventFilter/GEMRawToDigi/BuildFile.xml @@ -2,7 +2,6 @@ - @@ -12,5 +11,5 @@ - + diff --git a/EventFilter/GEMRawToDigi/interface/AMC13Event.h b/EventFilter/GEMRawToDigi/interface/AMC13Event.h index 0a2d3467e1482..124ba132a0296 100644 --- a/EventFilter/GEMRawToDigi/interface/AMC13Event.h +++ b/EventFilter/GEMRawToDigi/interface/AMC13Event.h @@ -4,70 +4,95 @@ #include "AMCdata.h" namespace gem { + + union CDFHeader { + uint64_t word; + struct { + uint64_t fov : 8; // not used + uint64_t sourceId : 12; // FED number assigned by CDAQ + uint64_t bxId : 12; // Bunch crossing 0...3563 + uint64_t lv1Id : 24; // Level 1 ID (hardware event number) + uint64_t eventType : 4; // Event Type (1 for normal, 2 for calibration) + uint64_t cb5 : 4; // 0x5 + }; + }; + union AMC13Header { + uint64_t word; + struct { + uint64_t cb0 : 4; // 0x0 + uint64_t orbitN : 32; // Orbit Number + uint64_t reserved0 : 16; // reserved + uint64_t nAMC : 4; // Number of AMCs following (0 to 12) + uint64_t calType : 4; // Calibration event type + uint64_t uFov : 4; // Format version: 0x1 + }; + }; + union AMC13Trailer { + uint64_t word; + struct { + uint64_t bxIdT : 12; // bx id + uint64_t lv1IdT : 8; // level 1 id + uint64_t blkN : 8; // block number + uint64_t crc32 : 36; // Overall CRC (first 34 bits) + }; + }; + union CDFTrailer { + uint64_t word; + struct { + uint64_t tts : 8; // tts (first 4 bits) + uint64_t evtStat : 4; // event status + uint64_t crcCDF : 20; // CDF crc (first 16 bits) + uint64_t evtLength : 24; // event length + uint64_t cbA : 8; // 0xA (first 4 bits) + }; + }; + class AMC13Event { + public: - AMC13Event(){} - ~AMC13Event(){m_amcHeaders.clear(); m_amcs.clear();} + AMC13Event() {} + ~AMC13Event() {amcHeaders_.clear(); amcs_.clear();} - int nAMC() const {return unsigned(m_nAMC);} - int bx_id() const {return unsigned(m_BX_id);} - int lv1_id() const {return unsigned(m_LV1_id);} - int source_id() const {return unsigned(m_Source_id);} - //const std::vector * amcs() const {return &m_amcs;} + void setCDFHeader(uint64_t word) { cdfh_ = word;} + void setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id); + uint64_t getCDFHeader() const { return cdfh_;} - uint64_t getCDFHeader() const; - void setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id); - void setCDFHeader(uint64_t word); + void setAMC13Header(uint64_t word) { amc13h_ = word;} + void setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN); + uint64_t getAMC13Header() const { return amc13h_;} - uint64_t getAMC13header() const; - void setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0); - void setAMC13header(uint64_t word); + void setAMC13Trailer(uint64_t word) { amc13t_ = word;} + void setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT); + uint64_t getAMC13Trailer() const { return amc13t_;} + + void setCDFTrailer(uint64_t word) { cdft_ = word;} + void setCDFTrailer(uint32_t EvtLength); + uint64_t getCDFTrailer() const { return cdft_;} + + uint16_t bxId() const {return CDFHeader{cdfh_}.bxId;} + uint32_t lv1Id() const {return CDFHeader{cdfh_}.lv1Id;} + uint16_t sourceId() const {return CDFHeader{cdfh_}.sourceId;} + + uint8_t nAMC() const {return AMC13Header{amc13h_}.nAMC;} - const std::vector * getAMCheaders() const {return &m_amcHeaders;} + const std::vector * getAMCheaders() const {return &amcHeaders_;} void addAMCheader(uint64_t word); void addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID); - const std::vector * getAMCpayloads() const {return &m_amcs;} - void addAMCpayload(const AMCdata& a){m_amcs.push_back(a);} - - uint64_t getAMC13trailer() const; - void setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT); - void setAMC13trailer(uint64_t word); - - uint64_t getCDFTrailer() const; - void setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf); - void setCDFTrailer(uint64_t word); + const std::vector * getAMCpayloads() const {return &amcs_;} + void addAMCpayload(const AMCdata& a) {amcs_.push_back(a);} private: - // CDF Header - uint8_t m_cb5; // control bit, should be 0x5 bits 60-63 - uint8_t m_Evt_ty; - uint32_t m_LV1_id; - uint16_t m_BX_id; - uint16_t m_Source_id; - // AMC13 header - uint8_t m_CalTyp; - uint8_t m_nAMC; - uint32_t m_OrN; - uint8_t m_cb0; // control bit, should be 0b0000 + uint64_t cdfh_; // CDFHeader + uint64_t amc13h_; // AMC13Header + uint64_t amc13t_; // AMC13Trailer + uint64_t cdft_; // CDFTrailer + // AMC headers - std::vector m_amcHeaders; - /* std::vector m_AMC_size; */ - /* std::vector m_Blk_No; */ - /* std::vector m_AMC_No; */ - /* std::vector m_BoardID; */ + std::vector amcHeaders_; // AMCs payload - std::vector m_amcs; - //AMC13 trailer - uint32_t m_CRC_amc13; - uint8_t m_Blk_NoT; - uint8_t m_LV1_idT; - uint16_t m_BX_idT; - //CDF trailer - uint8_t m_cbA; // control bit, should be 0xA bits 60-63 - uint32_t m_EvtLength; - uint16_t m_CRC_cdf; + std::vector amcs_; }; } diff --git a/EventFilter/GEMRawToDigi/interface/AMCdata.h b/EventFilter/GEMRawToDigi/interface/AMCdata.h index 73d7f403f8d46..6cf23d224995f 100644 --- a/EventFilter/GEMRawToDigi/interface/AMCdata.h +++ b/EventFilter/GEMRawToDigi/interface/AMCdata.h @@ -1,259 +1,117 @@ #ifndef EventFilter_GEMRawToDigi_AMCdata_h #define EventFilter_GEMRawToDigi_AMCdata_h -#include #include "GEBdata.h" -//!A class for AMC data -/** - The number after the ":" indicates how many bits a certain item consists of. -*/ +#include + namespace gem { + + union AMCheader1 { + uint64_t word; + struct { + uint64_t dataLength : 20; // Overall size of this FED event fragment + uint64_t bxID : 12; // Bunch crossing ID + uint64_t l1AID : 24; // L1A number – basically this is like event number, but it’s reset by resync + uint64_t AMCnum : 4; // Slot number of the AMC + uint64_t reserved : 4; // not used + }; + }; + union AMCheader2 { + uint64_t word; + struct { + uint64_t boardID : 16; // 8bit long GLIB serial number + uint64_t orbitNum : 16; + uint64_t param3 : 8; + uint64_t param2 : 8; + uint64_t param1 : 8; + uint64_t runType : 4; // run types like physics, cosmics, threshold scan, latency scan, etc.. + uint64_t formatVer : 4; // Current format version = 0x0 + }; + }; + union AMCTrailer { + uint64_t word; + struct { + uint64_t dataLengthT: 20; // Overall size of this FED event fragment + uint64_t l1AIDT : 12; // 8bit long GLIB serial number (first 8 bits) + uint64_t crc : 32; + }; + }; + union EventHeader { + uint64_t word; + struct { + uint64_t ttsState : 11; // GLIB TTS state at the moment when this event was built. + uint64_t davCnt : 5; // Number of chamber blocks + uint64_t buffState : 24; // buffer error + uint64_t davList : 24; // Bitmask indicating which inputs/chambers have data + }; + }; + union EventTrailer { + uint64_t word; + struct { + uint64_t oosGlib : 40; // GLIB is out‐of‐sync (critical): L1A ID is different for different chambers in this event (1 bit) + uint64_t chTimeOut : 24; // GLIB did not receive data from a particular input for this L1A + }; + }; + class AMCdata { - public: - //!Constructor for the class - AMCdata(){}; - AMCdata(const uint8_t AMCnum_, - const uint32_t L1A_, - const uint16_t BX_, - const uint32_t Dlength_, - const uint8_t FV_, - const uint8_t Rtype_, - const uint8_t Param1_, - const uint8_t Param2_, - const uint8_t Param3_, - const uint16_t Onum_, - const uint16_t BID_, - const uint32_t GEMDAV_, - const uint64_t Bstatus_, - const uint8_t GDcount_, - const uint8_t Tstate_, - const uint32_t ChamT_, - const uint8_t OOSG_) : - m_AMCnum(AMCnum_), - m_L1A(L1A_), - m_BX(BX_), - m_Dlength(Dlength_), - m_FV(FV_), - m_Rtype(Rtype_), - m_Param1(Param1_), - m_Param2(Param2_), - m_Param3(Param3_), - m_Onum(Onum_), - m_BID(BID_), - m_GEMDAV(GEMDAV_), - m_Bstatus(Bstatus_), - m_GDcount(GDcount_), - m_Tstate(Tstate_), - m_ChamT(ChamT_), - m_OOSG(OOSG_){} - //!Destructor for the class - ~AMCdata(){gebd.clear();} - - //!Reads the word for AMC Header - //Fills the AMC number, L1A ID, BX ID, and Data Length - void setAMCheader1(uint64_t word) - { - m_AMCnum = 0x0f & (word >> 56); /*!> 32); /*!> 20); /*!(m_AMCnum & 0x0f) << 56) | - (static_cast(m_L1A & 0x00ffffff) << 32) | - (static_cast(m_BX & 0x0fff) << 20) | - (static_cast(m_Dlength & 0x000fffff)); - } - //!Reads the word for the AMC Header 2 - // Fills the Format Version, Run Type, Run Param 1, Run Param 2, Run Param 3, Orbit Number, and Board ID - void setAMCheader2(uint64_t word) - { - m_FV = 0x0f & (word >> 60); /*!> 56); /*!> 48; /*!> 40; /*!> 32; /*!> 16; /*!(m_FV & 0x0f) << 60) | - (static_cast(m_Rtype & 0x0f) << 56) | - (static_cast(m_Param1) << 48) | - (static_cast(m_Param2) << 40) | - (static_cast(m_Param3) << 32) | - (static_cast(m_Onum) << 16) | - (static_cast(m_BID)); - } + public: + AMCdata() {}; + ~AMCdata() {gebd_.clear();} + + void setAMCheader1(uint64_t word) { amch1_ = word;} + void setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum); + uint64_t getAMCheader1() const { return amch1_;} + + void setAMCheader2(uint64_t word) { amch2_ = word;} + void setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType); + uint64_t getAMCheader2() const { return amch2_;} + + void setAMCTrailer(uint64_t word) { amct_ = word;} + uint64_t getAMCTrailer() const { return amct_;} + + void setGEMeventHeader(uint64_t word) { eh_ = word;} + void setGEMeventHeader(uint8_t davCnt, uint32_t davList); + uint64_t getGEMeventHeader() const { return eh_;} + + void setGEMeventTrailer(uint64_t word) { et_ = word;} + uint64_t getGEMeventTrailer() const { return et_;} + + uint32_t dataLength() const {return AMCheader1{amch1_}.dataLength;} + uint16_t bx() const {return AMCheader1{amch1_}.bxID;} + uint32_t l1A() const {return AMCheader1{amch1_}.l1AID;} + uint8_t amcNum() const {return AMCheader1{amch1_}.AMCnum;} + + uint16_t boardId() const {return AMCheader2{amch2_}.boardID;} + uint16_t orbitNum() const {return AMCheader2{amch2_}.orbitNum;} + uint8_t param3() const {return AMCheader2{amch2_}.param3;} + uint8_t param2() const {return AMCheader2{amch2_}.param2;} + uint8_t param1() const {return AMCheader2{amch2_}.param1;} + uint8_t runType() const {return AMCheader2{amch2_}.runType;} + uint8_t formatVer() const {return AMCheader2{amch2_}.formatVer;} - //!Reads the word for the GEM Event Header - // Fills the GEM DAV list, Buffer Status, GEM DAV count, and TTS state. - void setGEMeventHeader(uint64_t word) - { - m_GEMDAV = 0x00ffffff & (word >> 40); /*!> 16); /*!> 11); /*!(m_GEMDAV & 0x00ffffff) << 40) | - (static_cast(m_Bstatus & 0x00ffffff) << 16) | - (static_cast(m_GDcount & 0b00011111) << 11) | - (static_cast(m_Tstate & 0b00000111)); - } - - //!Reads the word for the GEM Event Trailer - // Fills the Chamber Timeout and OOS GLIB. - void setGEMeventTrailer(uint64_t word) - { - m_ChamT = 0x00ffffff & (word >> 40); /*!> 39); /*!(m_ChamT & 0x00ffffff) << 40) | - (static_cast(m_OOSG & 0b00000001) << 39); - } + uint16_t ttsState() const {return EventHeader{eh_}.ttsState;} + uint8_t davCnt() const {return EventHeader{eh_}.davCnt;} + uint32_t buffState() const {return EventHeader{eh_}.buffState;} + uint32_t davList() const {return EventHeader{eh_}.davList;} - //!Reads the word for the AMC Trailer - void setAMCTrailer(uint64_t word) - { - m_CRC = word >> 32; - m_L1AT = word >> 24; - m_DlengthT = 0x000fffff & word; - } - uint64_t getAMCTrailer() const - { - return - (static_cast(m_CRC) << 32) | - (static_cast(m_L1AT) << 24) | - (static_cast(m_DlengthT & 0x000fffff)); - } - - uint8_t amcNum() const {return m_AMCnum;} /// * gebs() const {return &gebd;} + const std::vector * gebs() const {return &gebd_;} private: - std::vector gebd; /// gebd_; /// #include "VFATdata.h" -//!A class for GEB data -/** - The number after the ":" indicates how many bits a certain item consists of. -*/ +#include + namespace gem { + // Input status 1 bit for each + // BX mismatch GLIB OH / BX mismatch GLIB VFAT / OOS GLIB OH / OOS GLIB VFAT / No VFAT marker + // Event size warn / L1AFIFO near full / InFIFO near full / EvtFIFO near full / Event size overflow + // L1AFIFO full / InFIFO full / EvtFIFO full + union GEBchamberHeader { + uint64_t word; + struct { + uint64_t inputStatus : 23; // Input status (critical) only first 13 bits used + uint64_t vfatWordCnt : 12; // Size of VFAT payload in 64bit words expected to send to AMC13 + uint64_t inputID : 5 ; // GLIB input ID (starting at 0) + uint64_t zeroSupWordsCnt : 24; // Bitmask indicating if certain VFAT blocks have been zero suppressed + }; + }; + union GEBchamberTrailer { + uint64_t word; + struct { + uint64_t ecOH : 20; // OH event counter + uint64_t bcOH : 14; // OH bunch crossing + uint64_t stuckData : 1; // Input status (warning): There was data in InFIFO or EvtFIFO when L1A FIFO was empty + uint64_t inFIFOund : 1; // Input status (critical): Input FIFO underflow occurred while sending this event + uint64_t vfatWordCntT : 12; // Size of VFAT payload in 64bit words sent to AMC13 + uint64_t ohcrc : 16; // CRC of OH data (currently not available – filled with 0) + }; + }; + class GEBdata { public: - GEBdata(){}; - ~GEBdata(){m_vfatd.clear();} + + GEBdata() {}; + ~GEBdata() {vfatd_.clear();} - // need to include all the flags - //!Reads the word for the GEM Chamber Header. Puts the thirteen flags in a vector. - /** - Fills the Zero Suppression, GLIB Input ID, VFAT word count, and Thirteen Flags. - */ - void setChamberHeader(uint64_t word) - { - m_ZeroSupWordsCnt = 0x0fff & (word >> 40); /*!Zero suppressed words counter*/ - m_InputID = 0b00011111 & (word >> 35); /*!> 23); /*!> i)); - } - } - uint64_t getChamberHeader() const + //!Read chamberHeader from the block. + void setChamberHeader(uint64_t word) { ch_ = word;} + void setChamberHeader(uint16_t vfatWordCnt, uint8_t inputID) { - return - (static_cast(m_ZeroSupWordsCnt & 0x0fff) << 40) | - (static_cast(m_InputID & 0b00011111) << 35) | - (static_cast(m_Vwh & 0x0fff) << 23) | - (static_cast(m_ErrorC & 0b0001111111111111)); + GEBchamberHeader u; + u.vfatWordCnt = vfatWordCnt; + u.inputID = inputID; + ch_ = u.word; } + uint64_t getChamberHeader() const { return ch_;} - //return specific flags - //!Returns one of thirteen flags from GEM chamber header. - /** - Argument must be between 0 and 12. The flags corresponding to a given argument are shown. - 12->EvtFIFO full 11->InFIFO full 10->L1AFIFO full 9->Even size overflow 8->EvtFIFO near full 5->InFIFO near full - 6->L1AFIFO near full 5->Event size warn 4->No VFAT marker 3->OOS GLIB VFAT 2->OOS GLIB OH - 1->BX mismatch GLIB VFAT 0->BX mismatch GLIB OH - */ - uint8_t getGEBflag(int c) const + //!Read chamberTrailer from the block. + void setChamberTrailer(uint64_t word) { ct_ = word;} + void setChamberTrailer(uint32_t ecOH, uint16_t bcOH, uint16_t vfatWordCntT) { - return m_GEBflags.at(c); - } - std::vector getGEBflag() const - { - return m_GEBflags; - } - // need to include all the flags - //!Reads the word for GEM Chamber Trailer - /** - Fills the OH CRC, VFAT word count, InFIFO underflow, Stuck data, OH BC and OH EC. - */ - void setChamberTrailer(uint64_t word) - { - m_OHCRC = word >> 48; /*!> 36); /*!> 35); /*!> 34); /*!> 20); /*!OH BC*/ - m_OHEC = 0x000fffff & (word); /*!OH EC*/ - } - uint64_t getChamberTrailer() const - { - return - (static_cast(m_OHCRC) << 48) | - (static_cast(m_Vwt & 0x0fff) << 36) | - (static_cast(m_InFu & 0x0f) << 35) | - (static_cast(m_Stuckd & 0x01) << 34) | - (static_cast(m_OHBC & 0x0fff) << 20) | - (static_cast(m_OHEC & 0x000fffff)); + GEBchamberTrailer u; + u.ecOH = ecOH; + u.bcOH = bcOH; + u.vfatWordCntT = vfatWordCntT; + ct_ = u.word; } + uint64_t getChamberTrailer() const { return ct_;} - void setVwh(uint16_t n){m_Vwh = n;} /// * vFATs() const {return &m_vfatd;} + const std::vector * vFATs() const {return &vfatd_;} static const int sizeGebID = 5; private: - std::vector m_vfatd; /// m_GEBflags; /// vfatd_; }; } #endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h b/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h new file mode 100644 index 0000000000000..ea2b1eb1453fd --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h @@ -0,0 +1,9 @@ +#ifndef DataFormats_GEMDigi_GEMAMC13EventCollection_h +#define DataFormats_GEMDigi_GEMAMC13EventCollection_h + +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" + +typedef MuonDigiCollection GEMAMC13EventCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h b/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h new file mode 100644 index 0000000000000..6c34d3e5d92ba --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h @@ -0,0 +1,9 @@ +#ifndef DataFormats_GEMDigi_GEMAMCdataCollection_h +#define DataFormats_GEMDigi_GEMAMCdataCollection_h + +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" + +typedef MuonDigiCollection GEMAMCdataCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h b/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h new file mode 100644 index 0000000000000..ba9b3cd8ef7a9 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h @@ -0,0 +1,10 @@ +#ifndef DataFormats_GEMDigi_GEMGEBdataCollection_h +#define DataFormats_GEMDigi_GEMGEBdataCollection_h + +#include "EventFilter/GEMRawToDigi/interface/GEBdata.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" + +typedef MuonDigiCollection GEMGEBdataCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h new file mode 100644 index 0000000000000..7e39f98208839 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h @@ -0,0 +1,28 @@ +#ifndef DataFormats_GEMDigi_GEMVfatStatusDigi_H +#define DataFormats_GEMDigi_GEMVfatStatusDigi_H + +#include +#include "EventFilter/GEMRawToDigi/interface/VFATdata.h" + +class GEMVfatStatusDigi { + + public: + GEMVfatStatusDigi(gem::VFATdata &vfat); + GEMVfatStatusDigi(){} + + uint8_t quality() const { return quality_; } + uint8_t flag() const { return flag_; } + int phi() const { return phi_; } + uint16_t bc() const { return bc_; } + uint8_t ec() const { return ec_; } + + private: + + uint8_t quality_; /// quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110 + uint8_t flag_; /// Control Flags: 4 bits, Hamming Error/AFULL/SEUlogic/SUEI2C + int phi_; /// vfat local phi postion in chamber + uint16_t bc_; + uint8_t ec_; + +}; +#endif diff --git a/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h new file mode 100644 index 0000000000000..36e50dc814745 --- /dev/null +++ b/EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h @@ -0,0 +1,10 @@ +#ifndef DataFormats_GEMDigi_GEMVfatStatusDigiCollection_h +#define DataFormats_GEMDigi_GEMVfatStatusDigiCollection_h + +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/MuonData/interface/MuonDigiCollection.h" + +typedef MuonDigiCollection GEMVfatStatusDigiCollection; + +#endif diff --git a/EventFilter/GEMRawToDigi/interface/VFATdata.h b/EventFilter/GEMRawToDigi/interface/VFATdata.h index b947ba3f04a8f..3662468ee6f12 100644 --- a/EventFilter/GEMRawToDigi/interface/VFATdata.h +++ b/EventFilter/GEMRawToDigi/interface/VFATdata.h @@ -1,215 +1,130 @@ #ifndef EventFilter_GEMRawToDigi_VFATdata_h #define EventFilter_GEMRawToDigi_VFATdata_h -#include +#include namespace gem { - class VFATdata + /// VFAT data structure - 3 words of 64 bits each + union VFATfirst { + uint64_t word; + // v3 dataformat + struct { + uint64_t msData1 : 16; ///checkCRC(); - } + public: + + VFATdata(); + // this constructor only used for packing sim digis + VFATdata(const int vfatVer, + const uint16_t BC, + const uint8_t EC, + const uint16_t chipID, + const uint64_t lsDatas, + const uint64_t msDatas); + ~VFATdata() {} //!Read first word from the block. - void read_fw(uint64_t word) - { - m_b1010 = 0x0f & (word >> 60); - m_BC = 0x0fff & (word >> 48); - m_b1100 = 0x0f & (word >> 44); - m_EC = word >> 36; - m_Flag = 0x0f & (word >> 32); - m_b1110 = 0x0f & (word >> 28); - m_ChipID = 0x0fff & (word >> 16); - m_msData = 0xffff000000000000 & (word << 48); - } - uint64_t get_fw() const - { - return - (static_cast(m_b1010 & 0x0f) << 60) | - (static_cast(m_BC & 0x0fff) << 48) | - (static_cast(m_b1100 & 0x0f) << 44) | - (static_cast(m_EC) << 36) | - (static_cast(m_Flag & 0x0f) << 32) | - (static_cast(m_b1110 & 0x0f) << 28) | - (static_cast(m_ChipID & 0x0fff) << 16) | - (static_cast(m_msData & 0xffff000000000000) >> 48); - } + void read_fw(uint64_t word) { fw_ = word;} + uint64_t get_fw() const { return fw_;} //!Read second word from the block. - void read_sw(uint64_t word) - { - m_msData = m_msData | (0x0000ffffffffffff & word >> 16); - m_lsData = 0xffff000000000000 & (word << 48); + void read_sw(uint64_t word) { sw_ = word;} + uint64_t get_sw() const { return sw_;} + + //!Read third word from the block. + void read_tw(uint64_t word) { tw_ = word;} + uint64_t get_tw() const { return tw_;} + + // local phi in chamber + void setPhi(int i) {phiPos_ = i;} + int phi() const {return phiPos_;} + + uint64_t lsData() const { + return uint64_t(VFATsecond{sw_}.lsData1) << 48 | VFATthird{tw_}.lsData2; } - uint64_t get_sw() const - { - return - (static_cast(m_msData & 0x0000ffffffffffff) << 16) | - (static_cast(m_lsData & 0xffff000000000000) >> 48); + uint64_t msData() const { + return uint64_t(VFATfirst{fw_}.msData1) << 48 | VFATsecond{sw_}.msData2; } - //!Read third word from the block. - void read_tw(uint64_t word) - { - m_lsData = m_lsData | (0x0000ffffffffffff & word >> 16); - m_crc = word; + uint16_t bc() const { + if (ver_==2) return VFATfirst{fw_}.bcV2; + return VFATfirst{fw_}.bc; } - // make write_word function - uint64_t get_tw() const - { - return - (static_cast(m_lsData & 0x0000ffffffffffff) << 16) | - (static_cast(m_crc)); + uint8_t ec() const { + if (ver_==2) return VFATfirst{fw_}.ecV2; + return VFATfirst{fw_}.ec; } - - uint8_t b1010 () const { return m_b1010; } - uint16_t bc () const { return m_BC; } - uint8_t b1100 () const { return m_b1100; } - uint8_t ec () const { return m_EC; } - uint8_t flag () const { return m_Flag; } - uint8_t b1110 () const { return m_b1110; } - uint16_t chipID () const { return m_ChipID; } - uint64_t lsData () const { return m_lsData; } - uint64_t msData () const { return m_msData; } - uint16_t crc () const { return m_crc; } - uint16_t crc_calc () const { return m_crc_calc; } - int slotNumber () const { return m_SlotNumber; } - bool isBlockGood() const { return m_isBlockGood;} - - uint16_t crc_cal(uint16_t crc_in, uint16_t dato) - { - uint16_t v = 0x0001; - uint16_t mask = 0x0001; - uint16_t d=0x0000; - uint16_t crc_temp = crc_in; - unsigned char datalen = 16; - for (int i=0; i>1 ^ 0x8408; - else crc_temp = crc_temp>>1; - v<<=1; - } - return(crc_temp); + uint16_t vfatId() const { + if (ver_==2) return VFATfirst{fw_}.chipID; + return VFATfirst{fw_}.pos; } - - uint16_t checkCRC() - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & m_b1010)<<12) | m_BC; - vfatBlockWords[10] = ((0x000f & m_b1100)<<12) | ((0x00ff & m_EC) <<4) | (0x000f & m_Flag); - vfatBlockWords[9] = ((0x000f & m_b1110)<<12) | m_ChipID; - vfatBlockWords[8] = (0xffff000000000000 & m_msData) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & m_msData) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & m_msData) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & m_msData); - vfatBlockWords[4] = (0xffff000000000000 & m_lsData) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & m_lsData) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & m_lsData) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & m_lsData); - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } - - uint16_t checkCRC(uint8_t b1010, uint16_t BC, uint8_t b1100, - uint8_t EC, uint8_t Flag, uint8_t b1110, - uint16_t ChipID, uint64_t msData, uint64_t lsData) - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & b1010)<<12) | BC; - vfatBlockWords[10] = ((0x000f & b1100)<<12) | ((0x00ff & EC) <<4) | (0x000f & Flag); - vfatBlockWords[9] = ((0x000f & b1110)<<12) | ChipID; - vfatBlockWords[8] = (0xffff000000000000 & msData) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & msData) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & msData) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & msData); - vfatBlockWords[4] = (0xffff000000000000 & lsData) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & lsData) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & lsData) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & lsData); + void setVersion(int i) {ver_ = i;} + int version() const {return ver_;} - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } - - uint16_t checkCRC(const VFATdata * vfatData) - { - uint16_t vfatBlockWords[12]; - vfatBlockWords[11] = ((0x000f & vfatData->b1010())<<12) | vfatData->bc(); - vfatBlockWords[10] = ((0x000f & vfatData->b1100())<<12) | ((0x00ff & vfatData->ec()) <<4) | (0x000f & vfatData->flag()); - vfatBlockWords[9] = ((0x000f & vfatData->b1110())<<12) | vfatData->chipID(); - vfatBlockWords[8] = (0xffff000000000000 & vfatData->msData()) >> 48; - vfatBlockWords[7] = (0x0000ffff00000000 & vfatData->msData()) >> 32; - vfatBlockWords[6] = (0x00000000ffff0000 & vfatData->msData()) >> 16; - vfatBlockWords[5] = (0x000000000000ffff & vfatData->msData()); - vfatBlockWords[4] = (0xffff000000000000 & vfatData->lsData()) >> 48; - vfatBlockWords[3] = (0x0000ffff00000000 & vfatData->lsData()) >> 32; - vfatBlockWords[2] = (0x00000000ffff0000 & vfatData->lsData()) >> 16; - vfatBlockWords[1] = (0x000000000000ffff & vfatData->lsData()); + /// quality flag - bit: 0 good, 1 crc fail, 2 b1010 fail, 3 b1100 fail, 4 b1110 + uint8_t quality(); - uint16_t crc_fin = 0xffff; - for (int i = 11; i >= 1; i--){ - crc_fin = this->crc_cal(crc_fin, vfatBlockWords[i]); - } - return(crc_fin); - } + /// v3 + uint8_t header () const {return VFATfirst{fw_}.header; } + uint8_t crcCheck () const {return VFATfirst{fw_}.crcCheck; } + uint8_t position () const {return VFATfirst{fw_}.pos; } + /// v2 + uint8_t b1010 () const { return VFATfirst{fw_}.b1010; } + uint8_t b1100 () const { return VFATfirst{fw_}.b1100; } + uint8_t b1110 () const { return VFATfirst{fw_}.b1110; } + uint8_t flag () const { return VFATfirst{fw_}.flag; } + uint16_t chipID () const { return VFATfirst{fw_}.chipID; } + uint16_t crc () const { return VFATthird{tw_}.crc; } + + uint16_t crc_cal(uint16_t crc_in, uint16_t dato); + uint16_t checkCRC(); + static const int nChannels = 128; static const int sizeChipID = 12; - private: + private: + int ver_; /// vfat version + int phiPos_; /// phi position of vfat in chamber - uint8_t m_b1010; ///<1010:4 Control bits, shoud be 1010 - uint16_t m_BC; /// + diff --git a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc index 552cd64d26406..c48cf85eb36dc 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.cc @@ -37,216 +37,190 @@ void GEMDigiToRawModule::fillDescriptions(edm::ConfigurationDescriptions & descr descriptions.add("gemPackerDefault", desc); } -std::shared_ptr GEMDigiToRawModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const +std::shared_ptr GEMDigiToRawModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); - if (useDBEMap_){ - edm::ESHandle gemEMapRcd; - iSetup.get().get(gemEMapRcd); - auto gemEMap = std::make_unique(*(gemEMapRcd.product())); - gemEMap->convert(*gemORmap); + auto gemROmap = std::make_shared(); + if (useDBEMap_) { + edm::ESHandle gemEMapRcd; + iSetup.get().get(gemEMapRcd); + auto gemEMap = std::make_unique(*(gemEMapRcd.product())); + gemEMap->convert(*gemROmap); gemEMap.reset(); } else { // no EMap in DB, using dummy - auto gemEMap = std::make_unique(); - gemEMap->convertDummy(*gemORmap); + auto gemEMap = std::make_unique(); + gemEMap->convertDummy(*gemROmap); gemEMap.reset(); } - return gemORmap; + return gemROmap; } void GEMDigiToRawModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::EventSetup const&) const { auto fedRawDataCol = std::make_unique(); - // Take digis from the event edm::Handle gemDigis; iEvent.getByToken( digi_token, gemDigis ); - + if (!gemDigis.isValid()) { + iEvent.put(std::move(fedRawDataCol)); + return; + } + auto gemROMap = runCache(iEvent.getRun().index()); std::vector> amc13Events; - // currently only one FEDRaw - amc13Events.reserve(1); - { - auto amc13Event = std::make_unique(); - - uint16_t amcId = 0, gebId = 0; - std::unique_ptr amcData; - std::unique_ptr gebData; + amc13Events.reserve(FEDNumbering::MAXGEMFEDID-FEDNumbering::MINGEMFEDID+1); - const std::map *roMapED = gemROMap->getRoMap(); - for (auto ro=roMapED->begin(); ro!=roMapED->end(); ++ro){ - GEMROmap::eCoord ec = ro->first; - GEMROmap::dCoord dc = ro->second; + for (unsigned int fedId=FEDNumbering::MINGEMFEDID; fedId<=FEDNumbering::MAXGEMFEDID; ++fedId) { + std::unique_ptr amc13Event = std::make_unique(); - if (amcId != ec.amcId || !amcData){ - amcId = ec.amcId; - amcData = std::make_unique(); - amcData->setBID(amcId); - amcData->setBX(GEMELMap::amcBX_); - } - - if (gebId != ec.gebId || !gebData){ - gebId = ec.gebId; - gebData = std::make_unique(); - gebData->setInputID(gebId); - } - - uint16_t vfatId = ec.vfatId; - GEMDetId gemId = dc.gemDetId; + for (uint8_t amcNum=0; amcNum < GEMeMap::maxAMCs_; ++amcNum) { + std::unique_ptr amcData = std::make_unique(); - for (uint16_t bc = 0; bc < 2*GEMELMap::amcBX_; ++bc){ - bool hasDigi = false; + for (uint8_t gebId=0; gebId < GEMeMap::maxGEBs_; ++gebId) { + std::unique_ptr gebData = std::make_unique(); + GEMROMapping::chamEC geb_ec{fedId, amcNum, gebId}; + + if (!gemROMap->isValidChamber(geb_ec)) continue; + GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec); - uint8_t b1010 =0xA; ///<1010:4 Control bits, shoud be 1010 - uint16_t BC =bc; ///get(gemId); - for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt){ + auto vfats = gemROMap->getVfats(geb_dc.detId); + for (auto vfat_ec : vfats) { - const GEMDigi & digi = (*digiIt); - if (digi.bx() != bc-GEMELMap::amcBX_) continue; - - int maxVFat = GEMELMap::maxVFatGE11_; - if (gemId.station() == 2) maxVFat = GEMELMap::maxVFatGE21_; + GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec); + GEMDetId gemId = vfat_dc.detId; + uint16_t vfatId = vfat_ec.vfatAdd; - int localStrip = digi.strip() - ((dc.iPhi-1)%maxVFat)*GEMELMap::maxChan_; - // skip strips not in current vFat - if (localStrip < 1 || localStrip > GEMELMap::maxChan_) continue; + for (uint16_t bc = 0; bc < 2*GEMeMap::amcBX_; ++bc) { + bool hasDigi = false; - hasDigi = true; + uint64_t lsData = 0; ///get(gemId); + for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt) { - GEMROmap::stripNum stMap = {dc.vfatType, localStrip}; - GEMROmap::channelNum chMap = gemROMap->hitPosition(stMap); + const GEMDigi & digi = (*digiIt); + if (digi.bx() != bc-GEMeMap::amcBX_) continue; - int chan = chMap.chNum; - uint64_t oneBit = 0x1; - if (chan < 64) lsData = lsData | (oneBit << chan); - else msData = msData | (oneBit << (chan-64)); + int localStrip = digi.strip() - vfat_dc.localPhi*GEMeMap::maxChan_; + + // skip strips not in current vFat + if (localStrip < 0 || localStrip > GEMeMap::maxChan_ -1) continue; - LogDebug("GEMDigiToRawModule") <<" vfatId "<hitPos(stMap); - } + if (chMap.chNum < 64) lsData |= 1UL << chMap.chNum; + else msData |= 1UL << (chMap.chNum-64); + + LogDebug("GEMDigiToRawModule") + << " fed: " << fedId + << " amc:" << int(amcNum) + << " geb:" << int(gebId) + << " vfat:"<< vfat_dc.localPhi + << ",type: "<< vfat_dc.vfatType + << " id:"<< gemId + << " ch:"<< chMap.chNum + << " st:"<< digi.strip() + << " bx:"<< digi.bx(); + + } - if (!hasDigi) continue; - // only make vfat with hits - auto vfatData = std::make_unique(b1010, BC, b1100, EC, Flag, b1110, vfatId, lsData, msData, - crc, crc_calc, SlotNumber, isBlockGood); - gebData->addVFAT(*vfatData); - } + if (!hasDigi) continue; + // only make vfat with hits + auto vfatData = std::make_unique(geb_dc.vfatVer, bc, 0, vfatId, lsData, msData); + gebData->addVFAT(*vfatData); + } + + } // end of vfats in GEB + + if (!gebData->vFATs()->empty()) { + gebData->setChamberHeader(gebData->vFATs()->size()*3, gebId); + gebData->setChamberTrailer(0, 0, gebData->vFATs()->size()*3); + amcData->addGEB(*gebData); + } + + } // end of GEB loop + + if (!amcData->gebs()->empty()) { + amcData->setAMCheader1(0, GEMeMap::amcBX_, 0, amcNum); + amcData->setAMCheader2(amcNum, 0, 1); + amcData->setGEMeventHeader(amcData->gebs()->size(), 0); + amc13Event->addAMCpayload(*amcData); + } - bool saveGeb = false; - bool saveAMC = false; - auto nx = std::next(ro); - // last vfat, save - if (nx == roMapED->end()){ - saveGeb = true; - saveAMC = true; - } - else { - // check if next vfat is in new geb or amc - GEMROmap::eCoord ecNext = nx->first; - if (ecNext.gebId != gebId) saveGeb = true; - if (ecNext.amcId != amcId) saveAMC = true; + } // end of AMC loop + + if (!amc13Event->getAMCpayloads()->empty()) { + // CDFHeader + uint32_t LV1_id = iEvent.id().event(); + uint16_t BX_id = iEvent.bunchCrossing(); + amc13Event->setCDFHeader(event_type_, LV1_id, BX_id, fedId); + + // AMC13header + uint8_t CalTyp = 1; + uint8_t nAMC = amc13Event->getAMCpayloads()->size(); + uint32_t OrN = 2; + amc13Event->setAMC13Header(CalTyp, nAMC, OrN); + + for (unsigned short i = 0; i < amc13Event->nAMC(); ++i) { + uint32_t AMC_size = 0; + uint8_t Blk_No = 0; + uint8_t AMC_No = 0; + uint16_t BoardID = 0; + amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID); } - - if (!gebData->vFATs()->empty() && saveGeb){ - gebData->setVwh(gebData->vFATs()->size()*3); - amcData->addGEB(*gebData); - } - if (!amcData->gebs()->empty() && saveAMC){ - amcData->setGDcount(amcData->gebs()->size()); - amc13Event->addAMCpayload(*amcData); - } - } - - // CDFHeader - uint8_t cb5 = 0x5;// control bit, should be 0x5 bits 60-63 - uint8_t Evt_ty = event_type_; - uint32_t LV1_id = iEvent.id().event(); - uint16_t BX_id = iEvent.bunchCrossing(); - uint16_t Source_id = FEDNumbering::MINGEMFEDID; - amc13Event->setCDFHeader(cb5, Evt_ty, LV1_id, BX_id, Source_id); - - // AMC13header - uint8_t CalTyp = 1; - uint8_t nAMC = amc13Event->getAMCpayloads()->size(); // currently only one AMC13Event - uint32_t OrN = 2; - uint8_t cb0 = 0b0000;// control bit, should be 0b0000 - amc13Event->setAMC13header(CalTyp, nAMC, OrN, cb0); - - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i){ - uint32_t AMC_size = 0; - uint8_t Blk_No = 0; - uint8_t AMC_No = 0; - uint16_t BoardID = 0; - amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID); - } - //AMC13 trailer - uint32_t CRC_amc13 = 0; - uint8_t Blk_NoT = 0; - uint8_t LV1_idT = 0; - uint16_t BX_idT = BX_id; - amc13Event->setAMC13trailer(CRC_amc13, Blk_NoT, LV1_idT, BX_idT); - //CDF trailer - uint8_t cbA = 0xA; // control bit, should be 0xA bits 60-63 - uint32_t EvtLength = 0; - uint16_t CRC_cdf = 0; - amc13Event->setCDFTrailer(cbA, EvtLength, CRC_cdf); - amc13Events.emplace_back(std::move(amc13Event)); - }// finished making amc13Event data + //AMC13 trailer + uint8_t Blk_NoT = 0; + uint8_t LV1_idT = 0; + uint16_t BX_idT = BX_id; + amc13Event->setAMC13Trailer(Blk_NoT, LV1_idT, BX_idT); + //CDF trailer + uint32_t EvtLength = 0; + amc13Event->setCDFTrailer(EvtLength); + amc13Events.emplace_back(std::move(amc13Event)); + }// finished making amc13Event data + + } // end of FED loop // read out amc13Events into fedRawData - for (const auto & amc13e : amc13Events){ + for (const auto & amc13e : amc13Events) { std::vector words; words.emplace_back(amc13e->getCDFHeader()); - words.emplace_back(amc13e->getAMC13header()); - + words.emplace_back(amc13e->getAMC13Header()); + for (const auto & w: *amc13e->getAMCheaders()) - words.emplace_back(w); + words.emplace_back(w); - for (const auto & amc : *amc13e->getAMCpayloads()){ + for (const auto & amc : *amc13e->getAMCpayloads()) { words.emplace_back(amc.getAMCheader1()); words.emplace_back(amc.getAMCheader2()); words.emplace_back(amc.getGEMeventHeader()); - - for (const auto & geb: *amc.gebs()){ - words.emplace_back(geb.getChamberHeader()); - - for (const auto & vfat: *geb.vFATs()){ - words.emplace_back(vfat.get_fw()); - words.emplace_back(vfat.get_sw()); - words.emplace_back(vfat.get_tw()); - } + + for (const auto & geb: *amc.gebs()) { + words.emplace_back(geb.getChamberHeader()); + + for (const auto & vfat: *geb.vFATs()) { + words.emplace_back(vfat.get_fw()); + words.emplace_back(vfat.get_sw()); + words.emplace_back(vfat.get_tw()); + } - words.emplace_back(geb.getChamberTrailer()); + words.emplace_back(geb.getChamberTrailer()); } words.emplace_back(amc.getGEMeventTrailer()); words.emplace_back(amc.getAMCTrailer()); } - words.emplace_back(amc13e->getAMC13trailer()); + words.emplace_back(amc13e->getAMC13Trailer()); words.emplace_back(amc13e->getCDFTrailer()); - FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->source_id()); + FEDRawData & fedRawData = fedRawDataCol->FEDData(amc13e->sourceId()); int dataSize = (words.size()) * sizeof(uint64_t); fedRawData.resize(dataSize); diff --git a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h index 1e14b8e5b4015..db558ff99c8b6 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h +++ b/EventFilter/GEMRawToDigi/plugins/GEMDigiToRawModule.h @@ -16,21 +16,21 @@ #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" -#include "CondFormats/DataRecord/interface/GEMELMapRcd.h" -#include "CondFormats/GEMObjects/interface/GEMELMap.h" -#include "CondFormats/GEMObjects/interface/GEMROmap.h" +#include "CondFormats/DataRecord/interface/GEMeMapRcd.h" +#include "CondFormats/GEMObjects/interface/GEMeMap.h" +#include "CondFormats/GEMObjects/interface/GEMROMapping.h" namespace edm { class ConfigurationDescriptions; } -class GEMDigiToRawModule : public edm::global::EDProducer > { +class GEMDigiToRawModule : public edm::global::EDProducer > { public: /// Constructor GEMDigiToRawModule(const edm::ParameterSet & pset); // global::EDProducer - std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; + std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {}; @@ -41,7 +41,7 @@ class GEMDigiToRawModule : public edm::global::EDProducer digi_token; - bool useDBEMap_; + bool useDBEMap_; }; DEFINE_FWK_MODULE(GEMDigiToRawModule); #endif diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc index 0f2ebfb1762b8..f4403ff71ef44 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc @@ -22,10 +22,11 @@ GEMRawToDigiModule::GEMRawToDigiModule(const edm::ParameterSet & pset) : unPackStatusDigis_(pset.getParameter("unPackStatusDigis")) { produces(); - if (unPackStatusDigis_){ + if (unPackStatusDigis_) { produces("vfatStatus"); - produces("GEBStatus"); - produces("AMCStatus"); + produces("gebStatus"); + produces("AMCdata"); + produces("AMC13Event"); } } @@ -38,43 +39,45 @@ void GEMRawToDigiModule::fillDescriptions(edm::ConfigurationDescriptions & descr descriptions.add("muonGEMDigisDefault", desc); } -std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const +std::shared_ptr GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const { - auto gemORmap = std::make_shared(); - if (useDBEMap_){ - edm::ESHandle gemEMapRcd; - iSetup.get().get(gemEMapRcd); - auto gemEMap = std::make_unique(*(gemEMapRcd.product())); - gemEMap->convert(*gemORmap); + auto gemROmap = std::make_shared(); + if (useDBEMap_) { + edm::ESHandle gemEMapRcd; + iSetup.get().get(gemEMapRcd); + auto gemEMap = std::make_unique(*(gemEMapRcd.product())); + gemEMap->convert(*gemROmap); gemEMap.reset(); } else { // no EMap in DB, using dummy - auto gemEMap = std::make_unique(); - gemEMap->convertDummy(*gemORmap); + auto gemEMap = std::make_unique(); + gemEMap->convertDummy(*gemROmap); gemEMap.reset(); } - return gemORmap; + return gemROmap; } void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::EventSetup const&) const { auto outGEMDigis = std::make_unique(); - auto outVfatStatus = std::make_unique(); - auto outGEBStatus = std::make_unique(); - auto outAMCStatus = std::make_unique(); + auto outVFATStatus = std::make_unique(); + auto outGEBStatus = std::make_unique(); + auto outAMCdata = std::make_unique(); + auto outAMC13Event = std::make_unique(); - // Take raw from the event + // Take raw from the event edm::Handle fed_buffers; iEvent.getByToken( fed_token, fed_buffers ); auto gemROMap = runCache(iEvent.getRun().index()); - for (unsigned int id=FEDNumbering::MINGEMFEDID; id<=FEDNumbering::MAXGEMFEDID; ++id){ - const FEDRawData& fedData = fed_buffers->FEDData(id); + for (unsigned int fedId=FEDNumbering::MINGEMFEDID; fedId<=FEDNumbering::MAXGEMFEDID; ++fedId) { + const FEDRawData& fedData = fed_buffers->FEDData(fedId); int nWords = fedData.size()/sizeof(uint64_t); LogDebug("GEMRawToDigiModule") <<" words " << nWords; + if (nWords<5) continue; const unsigned char * data = fedData.data(); @@ -83,150 +86,138 @@ void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event & iEvent, edm::Ev const uint64_t* word = reinterpret_cast(data); amc13Event->setCDFHeader(*word); - amc13Event->setAMC13header(*(++word)); - + amc13Event->setAMC13Header(*(++word)); + // Readout out AMC headers - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i) + for (uint8_t i = 0; i < amc13Event->nAMC(); ++i) amc13Event->addAMCheader(*(++word)); // Readout out AMC payloads - for (unsigned short i = 0; i < amc13Event->nAMC(); ++i){ + for (uint8_t i = 0; i < amc13Event->nAMC(); ++i) { auto amcData = std::make_unique(); amcData->setAMCheader1(*(++word)); amcData->setAMCheader2(*(++word)); amcData->setGEMeventHeader(*(++word)); - uint16_t amcId = amcData->boardId(); uint16_t amcBx = amcData->bx(); + uint8_t amcNum = amcData->amcNum(); // Fill GEB - for (unsigned short j = 0; j < amcData->gdCount(); ++j){ + for (uint8_t j = 0; j < amcData->davCnt(); ++j) { auto gebData = std::make_unique(); gebData->setChamberHeader(*(++word)); - unsigned int m_nvb = gebData->vwh() / 3; // number of VFAT2 blocks - uint16_t gebId = gebData->inputID(); - GEMDetId gemId(-1,1,1,1,1,0); // temp ID - for (unsigned short k = 0; k < m_nvb; k++){ + uint8_t gebId = gebData->inputID(); + GEMROMapping::chamEC geb_ec = {fedId, amcNum, gebId}; + GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec); + GEMDetId gemChId = geb_dc.detId; + + for (uint16_t k = 0; k < gebData->vfatWordCnt()/3; k++) { auto vfatData = std::make_unique(); vfatData->read_fw(*(++word)); vfatData->read_sw(*(++word)); vfatData->read_tw(*(++word)); - gebData->addVFAT(*vfatData); - - uint16_t bc=vfatData->bc(); - uint8_t b1010=vfatData->b1010(); - uint8_t b1100=vfatData->b1100(); - uint8_t b1110=vfatData->b1110(); - uint16_t vfatId=vfatData->chipID(); - uint16_t crc = vfatData->crc(); - uint16_t crc_check = vfatData->checkCRC(); - bool Quality = (b1010==10) && (b1100==12) && (b1110==14) && (crc==crc_check); - - if (crc!=crc_check) edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :"<isValidChipID(ec)){ - edm::LogWarning("GEMRawToDigiModule") << "InValid ChipID :"<setVersion(geb_dc.vfatVer); + uint16_t vfatId = vfatData->vfatId(); + GEMROMapping::vfatEC vfat_ec = {vfatId, gemChId}; + + // check if ChipID exists. + if (!gemROMap->isValidChipID(vfat_ec)) { + edm::LogWarning("GEMRawToDigiModule") << "InValid: amcNum "<< int(amcNum) + << " gebId "<< int(gebId) + << " vfatId "<< int(vfatId) + << " vfat Pos "<< int(vfatData->position()); continue; } - + // check vfat data + if (vfatData->quality()) { + edm::LogWarning("GEMRawToDigiModule") << "Quality "<< int(vfatData->quality()) + << " b1010 "<< int(vfatData->b1010()) + << " b1100 "<< int(vfatData->b1100()) + << " b1110 "<< int(vfatData->b1110()); + if (vfatData->crc() != vfatData->checkCRC() ) { + edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :" + <crc()<<" "<checkCRC(); + } + } + + GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec); + + vfatData->setPhi(vfat_dc.localPhi); + GEMDetId gemId = vfat_dc.detId; + uint16_t bc=vfatData->bc(); + // strip bx = vfat bx - amc bx + int bx = bc-amcBx; + for (int chan = 0; chan < VFATdata::nChannels; ++chan) { uint8_t chan0xf = 0; if (chan < 64) chan0xf = ((vfatData->lsData() >> chan) & 0x1); else chan0xf = ((vfatData->msData() >> (chan-64)) & 0x1); // no hits - if(chan0xf==0) continue; - GEMROmap::dCoord dc = gemROMap->hitPosition(ec); - // strip bx = vfat bx - amc bx - int bx = bc-amcBx; - gemId = dc.gemDetId; - - GEMROmap::channelNum chMap = {dc.vfatType, chan}; - GEMROmap::stripNum stMap = gemROMap->hitPosition(chMap); - - int maxVFat = GEMELMap::maxVFatGE11_; - if (gemId.station() == 2) maxVFat = GEMELMap::maxVFatGE21_; - int stripId = stMap.stNum + (dc.iPhi-1)%maxVFat*GEMELMap::maxChan_; + if (chan0xf==0) continue; + + GEMROMapping::channelNum chMap = {vfat_dc.vfatType, chan}; + GEMROMapping::stripNum stMap = gemROMap->hitPos(chMap); + int stripId = stMap.stNum + vfatData->phi()*GEMeMap::maxChan_; + GEMDigi digi(stripId,bx); - LogDebug("GEMRawToDigiModule") <<" vfatId "<insertDigi(gemId,digi); + LogDebug("GEMRawToDigiModule") + << " fed: " << fedId + << " amc:" << int(amcNum) + << " geb:" << int(gebId) + << " vfat:"<< vfat_dc.localPhi + << ",type: "<< vfat_dc.vfatType + << " id:"<< gemId + << " ch:"<< chMap.chNum + << " st:"<< digi.strip() + << " bx:"<< digi.bx(); + + outGEMDigis.get()->insertDigi(gemId,digi); + + }// end of channel loop + + if (unPackStatusDigis_) { + outVFATStatus.get()->insertDigi(gemId, GEMVfatStatusDigi(*vfatData)); } - if (unPackStatusDigis_){ - GEMVfatStatusDigi vfatStatus(vfatData->lsData(), vfatData->msData(), - crc, vfatData->crc_calc(), - b1010, b1100, b1110, vfatData->flag(), - vfatData->isBlockGood()); - outVfatStatus.get()->insertDigi(gebData->inputID(),vfatStatus); - } - - } + } // end of vfat loop gebData->setChamberTrailer(*(++word)); - if (unPackStatusDigis_){ - GEMGEBStatusDigi gebStatus(gebData->zeroSupWordsCnt(), - gebData->vwh(), - gebData->errorC(), - gebData->ohCRC(), - gebData->vwt(), - gebData->inFu(), - gebData->inputID(), - gebData->stuckd(), - gebData->getGEBflag()); - outGEBStatus.get()->insertDigi(gebData->inputID(),gebStatus); + + if (unPackStatusDigis_) { + outGEBStatus.get()->insertDigi(gemChId.chamberId(), (*gebData)); } - - amcData->addGEB(*gebData); - } + + } // end of geb loop amcData->setGEMeventTrailer(*(++word)); amcData->setAMCTrailer(*(++word)); - - if (unPackStatusDigis_){ - GEMAMCStatusDigi amcStatus(amcData->amcNum(), - amcData->l1A(), - amcData->bx(), - amcData->dlength(), - amcData->fv(), - amcData->runType(), - amcData->param1(), - amcData->param2(), - amcData->param3(), - amcData->orbitNum(), - amcData->boardId(), - amcData->gemDAV(), - amcData->bStatus(), - amcData->gdCount(), - amcData->ttsState(), - amcData->chamberTimeOut(), - amcData->oosGLIB()); - outAMCStatus.get()->insertDigi(amcData->boardId(), amcStatus); + + if (unPackStatusDigis_) { + outAMCdata.get()->insertDigi(amcData->boardId(), (*amcData)); } - amc13Event->addAMCpayload(*amcData); - } + } // end of amc loop - amc13Event->setAMC13trailer(*(++word)); + amc13Event->setAMC13Trailer(*(++word)); amc13Event->setCDFTrailer(*(++word)); - } + + if (unPackStatusDigis_) { + outAMC13Event.get()->insertDigi(amc13Event->bxId(), AMC13Event(*amc13Event)); + } + + } // end of amc13Event iEvent.put(std::move(outGEMDigis)); - if (unPackStatusDigis_){ - iEvent.put(std::move(outVfatStatus), "vfatStatus"); - iEvent.put(std::move(outGEBStatus), "GEBStatus"); - iEvent.put(std::move(outAMCStatus), "AMCStatus"); + + if (unPackStatusDigis_) { + iEvent.put(std::move(outVFATStatus), "vfatStatus"); + iEvent.put(std::move(outGEBStatus), "gebStatus"); + iEvent.put(std::move(outAMCdata), "AMCdata"); + iEvent.put(std::move(outAMC13Event), "AMC13Event"); } + } diff --git a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h index 9952fb91d7a2d..82b2bc37ad687 100644 --- a/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h +++ b/EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h @@ -15,13 +15,14 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMVfatStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMGEBStatusDigiCollection.h" -#include "DataFormats/GEMDigi/interface/GEMAMCStatusDigiCollection.h" - -#include "CondFormats/DataRecord/interface/GEMELMapRcd.h" -#include "CondFormats/GEMObjects/interface/GEMELMap.h" -#include "CondFormats/GEMObjects/interface/GEMROmap.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h" + +#include "CondFormats/DataRecord/interface/GEMeMapRcd.h" +#include "CondFormats/GEMObjects/interface/GEMeMap.h" +#include "CondFormats/GEMObjects/interface/GEMROMapping.h" #include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" #include "EventFilter/GEMRawToDigi/interface/VFATdata.h" @@ -29,13 +30,13 @@ namespace edm { class ConfigurationDescriptions; } -class GEMRawToDigiModule : public edm::global::EDProducer > { +class GEMRawToDigiModule : public edm::global::EDProducer > { public: /// Constructor GEMRawToDigiModule(const edm::ParameterSet & pset); // global::EDProducer - std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; + std::shared_ptr globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; void globalEndRun(edm::Run const&, edm::EventSetup const&) const override {}; diff --git a/EventFilter/GEMRawToDigi/src/AMC13Event.cc b/EventFilter/GEMRawToDigi/src/AMC13Event.cc index 52d2b0b817a8a..c9d780af9e2e2 100644 --- a/EventFilter/GEMRawToDigi/src/AMC13Event.cc +++ b/EventFilter/GEMRawToDigi/src/AMC13Event.cc @@ -3,70 +3,47 @@ using namespace gem; -uint64_t AMC13Event::getCDFHeader() const +void AMC13Event::setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id) { - // CDF Header word - // 63 - 60 | 59 - 56 | 55 - 32 | 31 - 20 | 19 - 8 | - // cb5 | Evt_ty | LV1_id | BX_id | Source_id | - return (static_cast(m_cb5 & 0x0f) << 60) | - (static_cast(m_Evt_ty & 0x0f) << 56) | - (static_cast(m_LV1_id & 0x00ffffff) << 32) | - (static_cast(m_BX_id & 0x0fff) << 20) | - (static_cast(m_Source_id & 0x0fff) << 8); + CDFHeader u; + u.cb5 = 0x5; + u.eventType = Evt_ty; + u.lv1Id = LV1_id; + u.bxId = BX_id; + u.sourceId = Source_id; + cdfh_ = u.word; } -void AMC13Event::setCDFHeader(uint64_t word) +void AMC13Event::setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN) { - m_cb5 = 0x0f & (word >> 60); - m_Evt_ty = 0x0f & (word >> 56); - m_LV1_id = 0x00ffffff & (word >> 32); - m_BX_id = 0x0fff & (word >> 20); - m_Source_id = 0x0fff & (word >> 8); + AMC13Header u; + u.cb0 = 0x0; + u.calType = CalTyp; + u.nAMC = nAMC; + u.orbitN = OrN; + amc13h_ = u.word; } -void AMC13Event::setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id) +void AMC13Event::setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT) { - m_cb5 = cb5; - m_Evt_ty = Evt_ty; - m_LV1_id = LV1_id; - m_BX_id = BX_id; - m_Source_id = Source_id; + AMC13Trailer u; + u.blkN = Blk_NoT; + u.lv1IdT = LV1_idT; + u.bxIdT = BX_idT; + amc13t_ = u.word; } -uint64_t AMC13Event::getAMC13header() const +void AMC13Event::setCDFTrailer(uint32_t EvtLength) { - // AMC13 Header word - // 63 - 60 | 59 - 56 | 55 - 52 | 51 - 36 | 35 - 4 | 4 - 0 | - // uFOV | CalTyp | nAMC | Reserved| OrN | cb0 | - return (static_cast(m_CalTyp & 0x0f) << 56) | - (static_cast(m_nAMC & 0x0f) << 52) | - (static_cast(m_OrN) << 4) | - (static_cast(m_cb0 & 0x0f)); -} - -void AMC13Event::setAMC13header(uint64_t word) -{ - m_CalTyp = 0x0f & (word >> 56); - m_nAMC = 0x0f & (word >> 52); - m_OrN = word >> 4; - m_cb0 = 0x0f & word; -} - -void AMC13Event::setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0) -{ - m_CalTyp = CalTyp; - m_nAMC = nAMC; - m_OrN = OrN; - m_cb0 = cb0; + CDFTrailer u; + u.cbA = 0xA; + u.evtLength = EvtLength; + cdft_ = u.word; } void AMC13Event::addAMCheader(uint64_t word) { - // m_AMC_size.push_back(0x00ffffff&(word>>32)); - // m_Blk_No.push_back(0xff&(word>>20)); - // m_AMC_No.push_back(0x0f&(word>>16)); - // m_BoardID.push_back(0xffff&word); - m_amcHeaders.push_back(word); + amcHeaders_.push_back(word); } void AMC13Event::addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID) @@ -79,56 +56,5 @@ void AMC13Event::addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, (static_cast(Blk_No & 0xff) << 20) | (static_cast(AMC_No & 0x0f) << 16) | (static_cast(BoardID & 0xffff)); - m_amcHeaders.push_back(word); -} - -uint64_t AMC13Event::getAMC13trailer() const -{ - // AMC13 trailer word - // 63 - 32 | 27 - 20 | 19 - 12 | 11 - 0 | - // CRC_amc13 | Blk_No | LV1_idT | BX_idT | - return (static_cast(m_CRC_amc13) << 32) | - (static_cast(m_Blk_NoT & 0xff) << 20) | - (static_cast(m_LV1_idT & 0xff) << 12) | - (static_cast(m_BX_idT & 0x0fff)); -} - -void AMC13Event::setAMC13trailer(uint64_t word) -{ - m_CRC_amc13 = word >> 32; - m_Blk_NoT = 0xff & (word >> 20); - m_LV1_idT = 0xff & (word >> 12); - m_BX_idT = 0x0fff & word; -} - -void AMC13Event::setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT) -{ - m_CRC_amc13 = CRC_amc13; - m_Blk_NoT = Blk_NoT; - m_LV1_idT = LV1_idT; - m_BX_idT = BX_idT; -} - -uint64_t AMC13Event::getCDFTrailer() const -{ - // CDF trailer word - // 63 - 60 | 55 - 32 | 31 - 16 | - // cbA | EvtLength | CRC_cdf | - return (static_cast(m_cbA & 0x0f) << 60) | - (static_cast(m_EvtLength & 0x00ffffff) << 32) | - (static_cast(m_CRC_cdf & 0xffff) << 16); -} - -void AMC13Event::setCDFTrailer(uint64_t word) -{ - m_cbA = 0x0f & (word >> 60); - m_EvtLength = 0x00ffffff & (word >> 32); - m_CRC_cdf = 0xffff & (word >> 16); -} - -void AMC13Event::setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf) -{ - m_cbA = cbA; - m_EvtLength = EvtLength; - m_CRC_cdf = CRC_cdf; + amcHeaders_.push_back(word); } diff --git a/EventFilter/GEMRawToDigi/src/AMCdata.cc b/EventFilter/GEMRawToDigi/src/AMCdata.cc new file mode 100644 index 0000000000000..459ba26f6c4e7 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/AMCdata.cc @@ -0,0 +1,31 @@ +#include +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" + +using namespace gem; + +void AMCdata::setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum) +{ + AMCheader1 u; + u.dataLength = dataLength; + u.bxID = bxID; + u.l1AID = l1AID; + u.AMCnum = AMCnum; + amch1_ = u.word; +} + +void AMCdata::setAMCheader2(uint16_t boardID, uint16_t orbitNum, uint8_t runType) +{ + AMCheader2 u; + u.boardID = boardID; + u.orbitNum = orbitNum; + u.runType = runType; + amch2_ = u.word; +} + +void AMCdata::setGEMeventHeader(uint8_t davCnt, uint32_t davList) +{ + EventHeader u; + u.davCnt = davCnt; + u.davList = davList; + eh_ = u.word; +} diff --git a/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc new file mode 100644 index 0000000000000..b2cedacc205d4 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/GEMVfatStatusDigi.cc @@ -0,0 +1,11 @@ +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include + +GEMVfatStatusDigi::GEMVfatStatusDigi(gem::VFATdata &vfat) +{ + quality_ = vfat.quality(); + flag_ = vfat.flag(); + phi_ = vfat.phi(); + ec_ = vfat.ec(); + bc_ = vfat.bc(); +}; diff --git a/EventFilter/GEMRawToDigi/src/VFATdata.cc b/EventFilter/GEMRawToDigi/src/VFATdata.cc new file mode 100644 index 0000000000000..3a50da4a86c18 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/VFATdata.cc @@ -0,0 +1,106 @@ +#include "EventFilter/GEMRawToDigi/interface/VFATdata.h" +#include +using namespace gem; + +VFATdata::VFATdata() { + ver_ = 1; +} + +VFATdata::VFATdata(const int vfatVer, + const uint16_t BC, + const uint8_t EC, + const uint16_t chipID, + const uint64_t lsDatas, + const uint64_t msDatas) +{ + // this constructor only used for packing sim digis + VFATfirst fw; + VFATsecond sw; + VFATthird tw; + + fw.word = 0; + sw.word = 0; + tw.word = 0; + fw.header = 0x1E; + + if (vfatVer == 3) { + fw.bc = BC; + fw.ec = EC; + fw.pos = chipID; + } + else { + fw.chipID = chipID; + fw.b1110 = 14; + fw.b1100 = 12; + fw.b1010 = 10; + fw.ecV2 = EC; + fw.bcV2 = BC; + } + + sw.lsData1 = lsDatas >> 48; + tw.lsData2 = lsDatas & 0x0000ffffffffffff; + + fw.msData1 = msDatas >> 48; + sw.msData2 = msDatas & 0x0000ffffffffffff; + ver_ = vfatVer; + + fw_ = fw.word; + sw_ = sw.word; + tw_ = tw.word; + // checkCRC only works after words are set + // checkCRC not yet implemented for v3 + tw.crc = checkCRC(); + // once crc is found, save new third word + tw_ = tw.word; +} + +uint8_t VFATdata::quality() { + uint8_t q = 0; + if (ver_ == 2) { + if (VFATthird{tw_}.crc != checkCRC()) q = 1; + if (VFATfirst{fw_}.b1010 != 10) q |= 1UL << 1; + if (VFATfirst{fw_}.b1100 != 12) q |= 1UL << 2; + if (VFATfirst{fw_}.b1110 != 14) q |= 1UL << 3; + } + // quality test not yet implemented in v3 + return q; +} + +uint16_t VFATdata::crc_cal(uint16_t crc_in, uint16_t dato) +{ + uint16_t v = 0x0001; + uint16_t mask = 0x0001; + uint16_t d=0x0000; + uint16_t crc_temp = crc_in; + unsigned char datalen = 16; + for (int i=0; i>1 ^ 0x8408; + else crc_temp = crc_temp>>1; + v<<=1; + } + return crc_temp; +} + +uint16_t VFATdata::checkCRC() +{ + uint16_t vfatBlockWords[12]; + vfatBlockWords[11] = ((0x000f & VFATfirst{fw_}.b1010)<<12) | VFATfirst{fw_}.bcV2; + vfatBlockWords[10] = ((0x000f & VFATfirst{fw_}.b1100)<<12) | ((0x00ff & VFATfirst{fw_}.ecV2) <<4) | (0x000f & VFATfirst{fw_}.flag); + vfatBlockWords[9] = ((0x000f & VFATfirst{fw_}.b1110)<<12) | VFATfirst{fw_}.chipID; + vfatBlockWords[8] = (0xffff000000000000 & msData()) >> 48; + vfatBlockWords[7] = (0x0000ffff00000000 & msData()) >> 32; + vfatBlockWords[6] = (0x00000000ffff0000 & msData()) >> 16; + vfatBlockWords[5] = (0x000000000000ffff & msData()); + vfatBlockWords[4] = (0xffff000000000000 & lsData()) >> 48; + vfatBlockWords[3] = (0x0000ffff00000000 & lsData()) >> 32; + vfatBlockWords[2] = (0x00000000ffff0000 & lsData()) >> 16; + vfatBlockWords[1] = (0x000000000000ffff & lsData()); + + uint16_t crc_fin = 0xffff; + for (int i = 11; i >= 1; i--) { + crc_fin = crc_cal(crc_fin, vfatBlockWords[i]); + } + return crc_fin; +} diff --git a/EventFilter/GEMRawToDigi/src/classes.h b/EventFilter/GEMRawToDigi/src/classes.h new file mode 100644 index 0000000000000..747f4509e1804 --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/classes.h @@ -0,0 +1,14 @@ +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigi.h" +#include "EventFilter/GEMRawToDigi/interface/GEMVfatStatusDigiCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/GEBdata.h" +#include "EventFilter/GEMRawToDigi/interface/GEMGEBdataCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/AMCdata.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMCdataCollection.h" + +#include "EventFilter/GEMRawToDigi/interface/AMC13Event.h" +#include "EventFilter/GEMRawToDigi/interface/GEMAMC13EventCollection.h" + +#include "DataFormats/Common/interface/Wrapper.h" +#include diff --git a/EventFilter/GEMRawToDigi/src/classes_def.xml b/EventFilter/GEMRawToDigi/src/classes_def.xml new file mode 100644 index 0000000000000..cd8951aee8bad --- /dev/null +++ b/EventFilter/GEMRawToDigi/src/classes_def.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EventFilter/GEMRawToDigi/test/unpackData-GEM.py b/EventFilter/GEMRawToDigi/test/unpackData-GEM.py index 1219c78b15c26..c4e7e38e218cc 100644 --- a/EventFilter/GEMRawToDigi/test/unpackData-GEM.py +++ b/EventFilter/GEMRawToDigi/test/unpackData-GEM.py @@ -93,10 +93,9 @@ # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('FWCore.MessageService.MessageLogger_cfi') -#process.load('Configuration.StandardSequences.GeometryRecoDB_cff') -#process.load('Configuration.Geometry.GeometryDB_cff') -process.load('Configuration.Geometry.GeometryExtended2017Reco_cff') -process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') process.load('Configuration.StandardSequences.SimL1Emulator_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') @@ -147,8 +146,16 @@ # Other statements from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2017_realistic', '') -#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:startup', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') + +process.GlobalTag.toGet = cms.VPSet( + cms.PSet( + #connect = cms.string('sqlite_fip:EventFilter/GEMRawToDigi/test/GEMeMap.db'), + connect = cms.string('sqlite_file:./GEMeMap.db'), + record = cms.string('GEMeMapRcd'), + tag = cms.string('GEMeMap_v4') + )) + # validation event filter process.load('EventFilter.L1TRawToDigi.validationEventFilter_cfi') @@ -161,13 +168,13 @@ process.dumpRaw = cms.EDAnalyzer( "DumpFEDRawDataProduct", token = cms.untracked.InputTag("rawDataCollector"), - feds = cms.untracked.vint32 ( 1467 ), + feds = cms.untracked.vint32 ( 1467,1468 ), dumpPayload = cms.untracked.bool ( options.dumpRaw ) ) # raw to digi process.load('EventFilter.GEMRawToDigi.muonGEMDigis_cfi') -process.load('EventFilter.GEMRawToDigi.GEMSQLiteCabling_cfi') +#process.load('EventFilter.GEMRawToDigi.GEMSQLiteCabling_cfi') process.muonGEMDigis.InputLabel = cms.InputTag('rawDataCollector') process.muonGEMDigis.useDBEMap = True @@ -210,9 +217,6 @@ process.output = cms.OutputModule( "PoolOutputModule", outputCommands = cms.untracked.vstring("keep *"), - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('path') - ), fileName = cms.untracked.string('gem_EDM.root') ) diff --git a/EventFilter/Utilities/src/json_value.cpp b/EventFilter/Utilities/src/json_value.cpp index 6387924d9b8a5..ed4570e09fcbc 100644 --- a/EventFilter/Utilities/src/json_value.cpp +++ b/EventFilter/Utilities/src/json_value.cpp @@ -219,7 +219,7 @@ Value::CZString::operator =( const CZString &other ) bool Value::CZString::operator<( const CZString &other ) const { - if ( cstr_ ) + if ( cstr_ and other.cstr_) return strcmp( cstr_, other.cstr_ ) < 0; return index_ < other.index_; } @@ -227,7 +227,7 @@ Value::CZString::operator<( const CZString &other ) const bool Value::CZString::operator==( const CZString &other ) const { - if ( cstr_ ) + if ( cstr_ and other.cstr_) return strcmp( cstr_, other.cstr_ ) == 0; return index_ == other.index_; } diff --git a/FWCore/Catalog/test/BuildFile.xml b/FWCore/Catalog/test/BuildFile.xml index 420cb9c57e7c0..a638653d6b164 100644 --- a/FWCore/Catalog/test/BuildFile.xml +++ b/FWCore/Catalog/test/BuildFile.xml @@ -1,5 +1,6 @@ + diff --git a/FWCore/Catalog/test/FileLocator_t.cpp b/FWCore/Catalog/test/FileLocator_t.cpp index 7766f63eaeb7b..33ca8e067889e 100644 --- a/FWCore/Catalog/test/FileLocator_t.cpp +++ b/FWCore/Catalog/test/FileLocator_t.cpp @@ -3,6 +3,7 @@ #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" #include "FWCore/PluginManager/interface/standard.h" #include "FWCore/PluginManager/interface/PluginManager.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include #include @@ -18,7 +19,9 @@ int main() { "process.SiteLocalConfigService = cms.Service('SiteLocalConfigService')\n"; //create the services - edm::ServiceToken tempToken = edm::ServiceRegistry::createServicesFromConfig(config); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); //make the services available edm::ServiceRegistry::Operate operate(tempToken); diff --git a/FWCore/Framework/bin/BuildFile.xml b/FWCore/Framework/bin/BuildFile.xml index bf56799ed708d..8bb7c68587958 100644 --- a/FWCore/Framework/bin/BuildFile.xml +++ b/FWCore/Framework/bin/BuildFile.xml @@ -70,7 +70,7 @@ - + @@ -84,5 +84,6 @@ - + + diff --git a/FWCore/Framework/bin/cmsRunPyDev.cpp b/FWCore/Framework/bin/cmsRunBoostPython.cpp similarity index 98% rename from FWCore/Framework/bin/cmsRunPyDev.cpp rename to FWCore/Framework/bin/cmsRunBoostPython.cpp index cf3ffe5e8a22f..e3472bb563268 100644 --- a/FWCore/Framework/bin/cmsRunPyDev.cpp +++ b/FWCore/Framework/bin/cmsRunBoostPython.cpp @@ -24,7 +24,7 @@ PSet script. See notes in EventProcessor.cpp for details about it. #include "FWCore/Utilities/interface/ConvertException.h" #include "FWCore/Utilities/interface/Presence.h" #include "FWCore/Utilities/interface/TimingServiceBase.h" -#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" +#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" #include "TError.h" #include "boost/program_options.hpp" @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) { context += fileName; std::shared_ptr processDesc; try { - std::unique_ptr parameterSet = edm::cmspybind11::readConfig(fileName, argc, argv); + std::unique_ptr parameterSet = edm::boost_python::readConfig(fileName, argc, argv); processDesc.reset(new edm::ProcessDesc(std::move(parameterSet))); } catch(cms::Exception& iException) { diff --git a/FWCore/Framework/interface/one/OutputModule.h b/FWCore/Framework/interface/one/OutputModule.h index eda3aac02b487..c89efe7aad14b 100644 --- a/FWCore/Framework/interface/one/OutputModule.h +++ b/FWCore/Framework/interface/one/OutputModule.h @@ -51,6 +51,9 @@ namespace edm { return WantsGlobalLuminosityBlockTransitions::value; } + SerialTaskQueue* globalRunsQueue() final { return globalRunsQueue_.queue();} + SerialTaskQueue* globalLuminosityBlocksQueue() final { return globalLuminosityBlocksQueue_.queue();} + // ---------- static member functions -------------------- // ---------- member functions --------------------------- @@ -61,6 +64,8 @@ namespace edm { const OutputModule& operator=(const OutputModule&) =delete; // stop default // ---------- member data -------------------------------- + impl::OptionalSerialTaskQueueHolder::value> globalRunsQueue_; + impl::OptionalSerialTaskQueueHolder::value> globalLuminosityBlocksQueue_; }; } diff --git a/FWCore/Framework/interface/one/OutputModuleBase.h b/FWCore/Framework/interface/one/OutputModuleBase.h index b136109b32edd..8e85a00a1fc14 100644 --- a/FWCore/Framework/interface/one/OutputModuleBase.h +++ b/FWCore/Framework/interface/one/OutputModuleBase.h @@ -102,8 +102,8 @@ namespace edm { bool wantsStreamRuns() const {return false;} bool wantsStreamLuminosityBlocks() const {return false;}; - SerialTaskQueue* globalRunsQueue() { return &runQueue_;} - SerialTaskQueue* globalLuminosityBlocksQueue() { return &luminosityBlockQueue_;} + virtual SerialTaskQueue* globalRunsQueue() { return nullptr; } + virtual SerialTaskQueue* globalLuminosityBlocksQueue() { return nullptr; } SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourcesAcquirer_; } @@ -128,6 +128,7 @@ namespace edm { ParameterSetID selectorConfig() const { return selector_config_id_; } void doPreallocate(PreallocationConfiguration const&); + virtual void preallocLumis(unsigned int) ; void doBeginJob(); void doEndJob(); diff --git a/FWCore/Framework/interface/one/outputmoduleAbilityToImplementor.h b/FWCore/Framework/interface/one/outputmoduleAbilityToImplementor.h index 4ca46dc7e5b8d..872526277e9f8 100644 --- a/FWCore/Framework/interface/one/outputmoduleAbilityToImplementor.h +++ b/FWCore/Framework/interface/one/outputmoduleAbilityToImplementor.h @@ -25,6 +25,8 @@ #include "FWCore/Framework/interface/one/moduleAbilities.h" #include "FWCore/Framework/interface/one/implementors.h" #include "FWCore/Framework/interface/one/OutputModuleBase.h" +#include "FWCore/Framework/interface/LuminosityBlockForOutput.h" +#include "FWCore/Framework/interface/RunForOutput.h" // forward declarations @@ -78,6 +80,61 @@ namespace edm { virtual void respondToOpenInputFile(FileBlock const&) = 0; virtual void respondToCloseInputFile(FileBlock const&) = 0; }; + + + template + class RunCacheHolder : public virtual OutputModuleBase { + public: + RunCacheHolder(edm::ParameterSet const& iPSet): OutputModuleBase(iPSet) {} + RunCacheHolder( RunCacheHolder const&) = delete; + RunCacheHolder& operator=(RunCacheHolder const&) = delete; + ~RunCacheHolder() noexcept(false) override {}; + protected: + C* runCache(edm::RunIndex iID) { return cache_.get(); } + C const* runCache(edm::RunIndex iID) const { return cache_.get(); } + private: + void doBeginRun_(edm::RunForOutput const&rp) final { + cache_ = globalBeginRun(rp); + } + void doEndRun_(edm::RunForOutput const&rp) final { + globalEndRun(rp); + cache_ = nullptr; // propagate_const has no reset() function + } + + virtual std::shared_ptr globalBeginRun(edm::RunForOutput const&) const = 0; + virtual void globalEndRun(edm::RunForOutput const&) = 0; + //When threaded we will have a container for N items whre N is # of simultaneous runs + edm::propagate_const> cache_; + }; + + template + class LuminosityBlockCacheHolder : public virtual OutputModuleBase { + public: + template + LuminosityBlockCacheHolder(edm::ParameterSet const& iPSet): OutputModuleBase(iPSet) {} + LuminosityBlockCacheHolder( LuminosityBlockCacheHolder const&) = delete; + LuminosityBlockCacheHolder& operator=(LuminosityBlockCacheHolder const&) = delete; + ~LuminosityBlockCacheHolder() noexcept(false) override {}; + protected: + void preallocLumis(unsigned int iNLumis) final { + caches_.reset( new std::shared_ptr[iNLumis]); + } + + C const* luminosityBlockCache(edm::LuminosityBlockIndex iID) const { return caches_[iID].get(); } + C* luminosityBlockCache(edm::LuminosityBlockIndex iID) { return caches_[iID].get(); } + private: + void doBeginLuminosityBlock_(edm::LuminosityBlockForOutput const& lp) final { + caches_[lp.index()] = globalBeginLuminosityBlock(lp); + } + void doEndLuminosityBlock_(edm::LuminosityBlockForOutput const& lp) final { + globalEndLuminosityBlock(lp); + caches_[lp.index()].reset(); + } + + virtual std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const&) const = 0; + virtual void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const&) = 0; + std::unique_ptr[]> caches_; + }; template struct AbilityToImplementor; @@ -100,6 +157,16 @@ namespace edm { struct AbilityToImplementor { typedef edm::one::outputmodule::InputFileWatcher Type; }; + + template + struct AbilityToImplementor> { + typedef edm::one::outputmodule::RunCacheHolder Type; + }; + + template + struct AbilityToImplementor> { + typedef edm::one::outputmodule::LuminosityBlockCacheHolder Type; + }; } } } diff --git a/FWCore/Framework/src/one/OutputModuleBase.cc b/FWCore/Framework/src/one/OutputModuleBase.cc index fe0ecfa1962f7..4a95640b33676 100644 --- a/FWCore/Framework/src/one/OutputModuleBase.cc +++ b/FWCore/Framework/src/one/OutputModuleBase.cc @@ -205,6 +205,8 @@ namespace edm { void OutputModuleBase::doPreallocate(PreallocationConfiguration const& iPC) { auto nstreams = iPC.numberOfStreams(); selectors_.resize(nstreams); + + preallocLumis(iPC.numberOfLuminosityBlocks()); bool seenFirst = false; for(auto& s : selectors_) { @@ -220,6 +222,8 @@ namespace edm { } } + void OutputModuleBase::preallocLumis(unsigned int ) {} + void OutputModuleBase::doBeginJob() { resourcesAcquirer_ = createAcquirer(); this->beginJob(); diff --git a/FWCore/Framework/test/eventprocessor_t.cppunit.cc b/FWCore/Framework/test/eventprocessor_t.cppunit.cc index 54b6b51091de6..1bcbdf30e8001 100644 --- a/FWCore/Framework/test/eventprocessor_t.cppunit.cc +++ b/FWCore/Framework/test/eventprocessor_t.cppunit.cc @@ -39,9 +39,9 @@ class testeventprocessor: public CppUnit::TestFixture { CPPUNIT_TEST(beginEndTest); CPPUNIT_TEST(cleanupJobTest); CPPUNIT_TEST(activityRegistryTest); - CPPUNIT_TEST(moduleFailureTest); CPPUNIT_TEST(endpathTest); CPPUNIT_TEST(serviceConfigSaveTest); + CPPUNIT_TEST(moduleFailureTest); CPPUNIT_TEST_SUITE_END(); public: diff --git a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc index 814e42ca399d5..8e989a8033fc5 100644 --- a/FWCore/Framework/test/one_outputmodule_t.cppunit.cc +++ b/FWCore/Framework/test/one_outputmodule_t.cppunit.cc @@ -43,7 +43,9 @@ class testOneOutputModule: public CppUnit::TestFixture CPPUNIT_TEST(basicTest); CPPUNIT_TEST(runTest); + CPPUNIT_TEST(runCacheTest); CPPUNIT_TEST(lumiTest); + CPPUNIT_TEST(lumiCacheTest); CPPUNIT_TEST(fileTest); CPPUNIT_TEST(resourceTest); @@ -56,7 +58,9 @@ class testOneOutputModule: public CppUnit::TestFixture void basicTest(); void runTest(); + void runCacheTest(); void lumiTest(); + void lumiCacheTest(); void fileTest(); void resourceTest(); @@ -143,7 +147,6 @@ class testOneOutputModule: public CppUnit::TestFixture } }; - class LumiOutputModule : public edm::one::OutputModule { public: using edm::one::OutputModuleBase::doPreallocate; @@ -168,6 +171,60 @@ class testOneOutputModule: public CppUnit::TestFixture ++m_count; } }; + + struct DummyCache {}; + + class RunCacheOutputModule : public edm::one::OutputModule> { + public: + using edm::one::OutputModuleBase::doPreallocate; + RunCacheOutputModule(edm::ParameterSet const& iPSet) : edm::one::OutputModuleBase(iPSet), edm::one::OutputModule>(iPSet) {} + mutable unsigned int m_count = 0; + void write(edm::EventForOutput const&) override { + ++m_count; + } + void writeRun(edm::RunForOutput const&) override { + ++m_count; + } + void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override { + ++m_count; + } + + std::shared_ptr globalBeginRun(edm::RunForOutput const&) const override { + ++m_count; + return std::shared_ptr{}; + } + + void globalEndRun(edm::RunForOutput const&) override { + ++m_count; + } + }; + + class LumiCacheOutputModule : public edm::one::OutputModule> { + public: + using edm::one::OutputModuleBase::doPreallocate; + LumiCacheOutputModule(edm::ParameterSet const& iPSet) : edm::one::OutputModuleBase(iPSet), edm::one::OutputModule>(iPSet) {} + mutable unsigned int m_count = 0; + void write(edm::EventForOutput const&) override { + ++m_count; + } + void writeRun(edm::RunForOutput const&) override { + ++m_count; + } + void writeLuminosityBlock(edm::LuminosityBlockForOutput const&) override { + ++m_count; + } + + + std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlockForOutput const&) const override { + ++m_count; + return std::shared_ptr{}; + } + + void globalEndLuminosityBlock(edm::LuminosityBlockForOutput const&) override { + ++m_count; + } + }; + class FileOutputModule : public edm::one::OutputModule { public: using edm::one::OutputModuleBase::doPreallocate; @@ -417,6 +474,30 @@ void testOneOutputModule::lumiTest() testTransitions(testProd, {Trans::kGlobalBeginLuminosityBlock, Trans::kEvent, Trans::kGlobalEndLuminosityBlock, Trans::kGlobalEndLuminosityBlock, Trans::kGlobalEndRun}); } +void testOneOutputModule::runCacheTest() +{ + //make the services available + edm::ServiceRegistry::Operate operate(serviceToken_); + + edm::ParameterSet pset; + auto testProd = std::make_shared(pset); + + CPPUNIT_ASSERT(0 == testProd->m_count); + testTransitions(testProd, {Trans::kGlobalBeginRun, Trans::kEvent, Trans::kGlobalEndLuminosityBlock, Trans::kGlobalEndRun, Trans::kGlobalEndRun}); +} + +void testOneOutputModule::lumiCacheTest() +{ + //make the services available + edm::ServiceRegistry::Operate operate(serviceToken_); + + edm::ParameterSet pset; + auto testProd = std::make_shared(pset); + + CPPUNIT_ASSERT(0 == testProd->m_count); + testTransitions(testProd, {Trans::kGlobalBeginLuminosityBlock, Trans::kEvent, Trans::kGlobalEndLuminosityBlock, Trans::kGlobalEndLuminosityBlock, Trans::kGlobalEndRun}); +} + void testOneOutputModule::fileTest() { //make the services available diff --git a/FWCore/Integration/test/BuildFile.xml b/FWCore/Integration/test/BuildFile.xml index f9934fbd76983..705558020be47 100644 --- a/FWCore/Integration/test/BuildFile.xml +++ b/FWCore/Integration/test/BuildFile.xml @@ -139,6 +139,7 @@ + diff --git a/FWCore/MessageLogger/src/classes.h b/FWCore/MessageLogger/src/classes.h index 6c133fc355446..17cd60f4a527d 100644 --- a/FWCore/MessageLogger/src/classes.h +++ b/FWCore/MessageLogger/src/classes.h @@ -1,8 +1,2 @@ #include #include "FWCore/MessageLogger/interface/ErrorSummaryEntry.h" - -namespace FWCore_MessageLogger { - struct dictionary { - std::vector w_v_es; - }; -} diff --git a/FWCore/MessageService/bin/BuildFile.xml b/FWCore/MessageService/bin/BuildFile.xml index b9338117af98e..e3a0ab9afa57d 100644 --- a/FWCore/MessageService/bin/BuildFile.xml +++ b/FWCore/MessageService/bin/BuildFile.xml @@ -2,7 +2,7 @@ - + diff --git a/FWCore/MessageService/bin/Standalone.cpp b/FWCore/MessageService/bin/Standalone.cpp index 0e5b71e5b66a7..f527bef2adc3e 100644 --- a/FWCore/MessageService/bin/Standalone.cpp +++ b/FWCore/MessageService/bin/Standalone.cpp @@ -18,6 +18,7 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/PluginManager/interface/ProblemTracker.h" #include "FWCore/Utilities/interface/Presence.h" +#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" #include "FWCore/PluginManager/interface/PresenceFactory.h" #include "FWCore/ServiceRegistry/interface/Service.h" @@ -101,7 +102,10 @@ int main(int, char* argv[]) { "}"; // D. Create the services. - edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config)); + std::unique_ptr params; + edm::makeParameterSets(config, params); + edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(std::move(params))); + // E. Make the services available. edm::ServiceRegistry::Operate operate(tempToken); diff --git a/FWCore/ParameterSetReader/BuildFile.xml b/FWCore/ParameterSetReader/BuildFile.xml index 904a3c494c81c..2076d3c42f00f 100644 --- a/FWCore/ParameterSetReader/BuildFile.xml +++ b/FWCore/ParameterSetReader/BuildFile.xml @@ -1,6 +1,6 @@ - + - + diff --git a/FWCore/ParameterSetReader/interface/ProcessDescImpl.h b/FWCore/ParameterSetReader/interface/ProcessDescImpl.h index ece823b7ee156..0e9dd3d1bfbcb 100644 --- a/FWCore/ParameterSetReader/interface/ProcessDescImpl.h +++ b/FWCore/ParameterSetReader/interface/ProcessDescImpl.h @@ -1,9 +1,9 @@ #ifndef FWCore_Framework_ProcessDescImpl_h #define FWCore_Framework_ProcessDescImpl_h -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" -using ProcessDescImpl = PythonProcessDesc; +using ProcessDescImpl = PyBind11ProcessDesc; #endif diff --git a/FWCore/ParameterSetReader/src/ParameterSetReader.cc b/FWCore/ParameterSetReader/src/ParameterSetReader.cc index 45c80d074a671..15cbaef11fc4f 100644 --- a/FWCore/ParameterSetReader/src/ParameterSetReader.cc +++ b/FWCore/ParameterSetReader/src/ParameterSetReader.cc @@ -1,27 +1,27 @@ #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" -#include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h" -#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h" +#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h" +#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h" std::unique_ptr edm::getPSetFromConfig(const std::string &config) { - return PythonProcessDesc(config).parameterSet(); + return PyBind11ProcessDesc(config).parameterSet(); } //its really the stuff in MakePythonParameterSets that should be in the different namespace //I'll do that if this setup is ok std::unique_ptr edm::readConfig(std::string const& config, int argc, char* argv[]) { - return edm::boost_python::readConfig(config,argc,argv); + return edm::cmspybind11::readConfig(config,argc,argv); } std::unique_ptr edm::readConfig(std::string const& config) { - return edm::boost_python::readConfig(config); + return edm::cmspybind11::readConfig(config); } void edm::makeParameterSets(std::string const& configtext, std::unique_ptr & main) { - edm::boost_python::makeParameterSets(configtext,main); + edm::cmspybind11::makeParameterSets(configtext,main); } std::unique_ptr edm::readPSetsFrom(std::string const& fileOrString) { - return edm::boost_python::readPSetsFrom(fileOrString); + return edm::cmspybind11::readPSetsFrom(fileOrString); } diff --git a/FWCore/PythonFramework/test/BuildFile.xml b/FWCore/PythonFramework/test/BuildFile.xml index 9619565892a6e..522ceec1ebf7f 100644 --- a/FWCore/PythonFramework/test/BuildFile.xml +++ b/FWCore/PythonFramework/test/BuildFile.xml @@ -7,5 +7,6 @@ + diff --git a/FWCore/ServiceRegistry/BuildFile.xml b/FWCore/ServiceRegistry/BuildFile.xml index 58cf91197d990..26e3a9a2b5cb2 100644 --- a/FWCore/ServiceRegistry/BuildFile.xml +++ b/FWCore/ServiceRegistry/BuildFile.xml @@ -1,7 +1,6 @@ - diff --git a/FWCore/ServiceRegistry/interface/ServiceRegistry.h b/FWCore/ServiceRegistry/interface/ServiceRegistry.h index 335e499330d1a..e5e966db3bab7 100644 --- a/FWCore/ServiceRegistry/interface/ServiceRegistry.h +++ b/FWCore/ServiceRegistry/interface/ServiceRegistry.h @@ -87,7 +87,7 @@ namespace edm { // ---------- member functions --------------------------- - static ServiceToken createServicesFromConfig(std::string const& config); + static ServiceToken createServicesFromConfig(std::unique_ptr params); public: // Made public (temporarily) at the request of Emilio Meschi. static ServiceToken createSet(std::vector&); diff --git a/FWCore/ServiceRegistry/src/ServiceRegistry.cc b/FWCore/ServiceRegistry/src/ServiceRegistry.cc index 315997fb8bb75..18f6bdb954b32 100644 --- a/FWCore/ServiceRegistry/src/ServiceRegistry.cc +++ b/FWCore/ServiceRegistry/src/ServiceRegistry.cc @@ -12,7 +12,6 @@ // user include files #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" -#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h" // system include files @@ -77,9 +76,7 @@ namespace edm { // ServiceToken - ServiceRegistry::createServicesFromConfig(std::string const& config) { - std::unique_ptr params; - makeParameterSets(config, params); + ServiceRegistry::createServicesFromConfig(std::unique_ptr params) { auto serviceSets = params->popVParameterSet(std::string("services")); //create the services diff --git a/FWCore/TestProcessor/BuildFile.xml b/FWCore/TestProcessor/BuildFile.xml index 500892db85659..7e9fbf8e3ba7b 100644 --- a/FWCore/TestProcessor/BuildFile.xml +++ b/FWCore/TestProcessor/BuildFile.xml @@ -1,7 +1,6 @@ - + - diff --git a/FastSimulation/BaseParticlePropagator/BuildFile.xml b/FastSimulation/BaseParticlePropagator/BuildFile.xml deleted file mode 100644 index 2f22d42730e80..0000000000000 --- a/FastSimulation/BaseParticlePropagator/BuildFile.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/FastSimulation/CaloHitMakers/test/testEcalHitMaker.cc b/FastSimulation/CaloHitMakers/test/testEcalHitMaker.cc index 13014863c0024..348e68f4d77d1 100644 --- a/FastSimulation/CaloHitMakers/test/testEcalHitMaker.cc +++ b/FastSimulation/CaloHitMakers/test/testEcalHitMaker.cc @@ -39,7 +39,7 @@ #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h" #include "FastSimulation/CaloHitMakers/interface/EcalHitMaker.h" #include "FastSimulation/CaloHitMakers/interface/HcalHitMaker.h" -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimEvent.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" diff --git a/FastSimulation/Calorimetry/interface/CalorimetryManager.h b/FastSimulation/Calorimetry/interface/CalorimetryManager.h index 42632371d813b..08c84d3f02113 100644 --- a/FastSimulation/Calorimetry/interface/CalorimetryManager.h +++ b/FastSimulation/Calorimetry/interface/CalorimetryManager.h @@ -5,7 +5,7 @@ #include "SimG4CMS/Calo/interface/CaloHitID.h" // FastSimulation headers -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FastSimulation/Calorimetry/interface/HCALResponse.h" #include "DataFormats/DetId/interface/DetId.h" #include "FastSimulation/Utilities/interface/FamosDebug.h" @@ -23,7 +23,6 @@ class FSimEvent; class FSimTrack; -class RawParticle; class CaloGeometryHelper; class Histos; class HSParameters; diff --git a/FastSimulation/Calorimetry/src/CalorimetryManager.cc b/FastSimulation/Calorimetry/src/CalorimetryManager.cc index 40242a5b8efd8..b04c177d0b56a 100644 --- a/FastSimulation/Calorimetry/src/CalorimetryManager.cc +++ b/FastSimulation/Calorimetry/src/CalorimetryManager.cc @@ -319,8 +319,8 @@ void CalorimetryManager::EMShowerSimulation(const FSimTrack& myTrack, } else { - myElec = (myPart) * xe; - myPosi = (myPart) * (1.-xe); + myElec = (myPart.momentum()) * xe; + myPosi = (myPart.momentum()) * (1.-xe); myElec.setVertex(myPart.vertex()); myPosi.setVertex(myPart.vertex()); thePart.push_back(&myElec); @@ -906,8 +906,8 @@ void CalorimetryManager::MuonMipSimulation(const FSimTrack& myTrack, RandomEngin if (segmentSizeinX0>0.001 && segments[iseg].material()==CaloSegment::PbWO4 ) { // The energy loss simulator float charge = (float)(myTrack.charge()); - ParticlePropagator theMuon(moment,trackPosition,charge,nullptr); - theMuon.setID(-(int)charge*13); + RawParticle p = rawparticle::makeMuon(charge < 0, moment, trackPosition); + ParticlePropagator theMuon(p,nullptr,nullptr,mySimEvent->theTable()); if ( energyLossECAL ) { energyLossECAL->updateState(theMuon, segmentSizeinX0, random); energy = energyLossECAL->deltaMom().E(); @@ -961,8 +961,8 @@ void CalorimetryManager::MuonMipSimulation(const FSimTrack& myTrack, RandomEngin if (segmentSizeinX0>0.001) { // The energy loss simulator float charge = (float)(myTrack.charge()); - ParticlePropagator theMuon(moment,trackPosition,charge,nullptr); - theMuon.setID(-(int)charge*13); + RawParticle p = rawparticle::makeMuon(charge < 0, moment, trackPosition); + ParticlePropagator theMuon(p,nullptr,nullptr,mySimEvent->theTable()); energyLossHCAL->updateState(theMuon, segmentSizeinX0, random); mipenergy = energyLossHCAL->deltaMom().E(); moment -= energyLossHCAL->deltaMom(); diff --git a/FastSimulation/Event/BuildFile.xml b/FastSimulation/Event/BuildFile.xml index 1d35fee62a083..2d94fb9790953 100644 --- a/FastSimulation/Event/BuildFile.xml +++ b/FastSimulation/Event/BuildFile.xml @@ -3,7 +3,7 @@ - + diff --git a/FastSimulation/Event/interface/FBaseSimEvent.h b/FastSimulation/Event/interface/FBaseSimEvent.h index 574d810915c98..9cb7a068352e6 100644 --- a/FastSimulation/Event/interface/FBaseSimEvent.h +++ b/FastSimulation/Event/interface/FBaseSimEvent.h @@ -9,7 +9,7 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" // Famos Headers -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexType.h" #include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexTypeFwd.h" diff --git a/FastSimulation/Event/interface/FSimTrack.h b/FastSimulation/Event/interface/FSimTrack.h index c470095adffab..67bc348fd091b 100644 --- a/FastSimulation/Event/interface/FSimTrack.h +++ b/FastSimulation/Event/interface/FSimTrack.h @@ -9,7 +9,7 @@ #include "SimDataFormats/Vertex/interface/SimVertex.h" // FAMOS headers -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include diff --git a/FastSimulation/Event/src/FBaseSimEvent.cc b/FastSimulation/Event/src/FBaseSimEvent.cc index c181e48feba77..a1937b148abdc 100644 --- a/FastSimulation/Event/src/FBaseSimEvent.cc +++ b/FastSimulation/Event/src/FBaseSimEvent.cc @@ -11,11 +11,13 @@ #include "DataFormats/Candidate/interface/Candidate.h" //FAMOS Headers +#include "FastSimulation/Particle/interface/pdg_functions.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include "FastSimulation/Event/interface/FBaseSimEvent.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimVertex.h" #include "FastSimulation/Event/interface/KineParticleFilter.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexType.h" @@ -211,9 +213,8 @@ FBaseSimEvent::fill(const std::vector& simTracks, // The next 3 lines to be then replaced by the previous line XYZTLorentzVector momentum(track.momentum().px(),track.momentum().py(), track.momentum().pz(),track.momentum().e()); - RawParticle part(momentum,position); + RawParticle part = makeParticle(theTable(),track.type(),momentum,position); // - part.setID(track.type()); //std::cout << "Ctau = " << part.PDGcTau() << std::endl; // Don't save tracks that have decayed immediately but for which no daughters // were saved (probably due to cuts on E, pT and eta) @@ -292,47 +293,46 @@ FBaseSimEvent::fill(const std::vector& simTracks, if ( mom.T() > 0. ) { // The particle to be propagated - myPart = BaseParticlePropagator(RawParticle(mom,pos),0.,0.,4.); - myPart.setCharge(myTrack.charge()); + myPart = BaseParticlePropagator(RawParticle(mom,pos,myTrack.charge()),0.,0.,4.); // Propagate to Preshower layer 1 myPart.propagateToPreshowerLayer1(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) && myPart.getSuccess()>0 ) - myTrack.setLayer1(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess()>0 ) + myTrack.setLayer1(myPart.particle(),myPart.getSuccess()); // Propagate to Preshower Layer 2 myPart.propagateToPreshowerLayer2(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) && myPart.getSuccess()>0 ) - myTrack.setLayer2(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess()>0 ) + myTrack.setLayer2(myPart.particle(),myPart.getSuccess()); // Propagate to Ecal Endcap myPart.propagateToEcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) ) - myTrack.setEcal(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) + myTrack.setEcal(myPart.particle(),myPart.getSuccess()); // Propagate to HCAL entrance myPart.propagateToHcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) ) - myTrack.setHcal(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) + myTrack.setHcal(myPart.particle(),myPart.getSuccess()); // Attempt propagation to HF for low pt and high eta - if ( myPart.cos2ThetaV()>0.8 || mom.T() < 3. ) { + if ( myPart.particle().cos2ThetaV()>0.8 || mom.T() < 3. ) { // Propagate to VFCAL entrance myPart.propagateToVFcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) ) - myTrack.setVFcal(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) + myTrack.setVFcal(myPart.particle(),myPart.getSuccess()); // Otherwise propagate to the HCAL exit and HO. } else { // Propagate to HCAL exit myPart.propagateToHcalExit(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) ) - myTrack.setHcalExit(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) + myTrack.setHcalExit(myPart.particle(),myPart.getSuccess()); // Propagate to HOLayer entrance myPart.setMagneticField(0); myPart.propagateToHOLayer(false); - if ( myTrack.notYetToEndVertex(myPart.vertex()) ) - myTrack.setHO(myPart,myPart.getSuccess()); + if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) + myTrack.setHO(myPart.particle(),myPart.getSuccess()); } } } @@ -489,8 +489,7 @@ FBaseSimEvent::addParticles(const HepMC::GenEvent& myGenEvent) { p->momentum().py(), p->momentum().pz(), p->momentum().e()); - RawParticle part(momentum, vertex(originVertex).position()); - part.setID(p->pdg_id()); + RawParticle part= makeParticle(theTable(),p->pdg_id(),momentum, vertex(originVertex).position()); // Add the particle to the event and to the various lists @@ -526,7 +525,6 @@ FBaseSimEvent::addParticles(const HepMC::GenEvent& myGenEvent) { } - int FBaseSimEvent::addSimTrack(const RawParticle* p, int iv, int ig, const HepMC::GenVertex* ev) { @@ -558,7 +556,7 @@ FBaseSimEvent::addSimTrack(const RawParticle* p, int iv, int ig, // A proper decay time is scheduled FSimTrack(p,iv,ig,trackId,this, ev->position().t()/10. - * p->PDGmass() + * pdg::mass(p->pid(), theTable()) / std::sqrt(p->momentum().Vect().Mag2())) : // No proper decay time is scheduled FSimTrack(p,iv,ig,trackId,this); diff --git a/FastSimulation/Event/src/KineParticleFilter.cc b/FastSimulation/Event/src/KineParticleFilter.cc index 978987edad1d4..e8a1efe80fb80 100644 --- a/FastSimulation/Event/src/KineParticleFilter.cc +++ b/FastSimulation/Event/src/KineParticleFilter.cc @@ -1,5 +1,5 @@ #include "FastSimulation/Event/interface/KineParticleFilter.h" -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" KineParticleFilter::KineParticleFilter(const edm::ParameterSet & cfg) diff --git a/FastSimulation/EventProducer/interface/FamosManager.h b/FastSimulation/EventProducer/interface/FamosManager.h index cc5f11158f800..97f8b3d12bb35 100644 --- a/FastSimulation/EventProducer/interface/FamosManager.h +++ b/FastSimulation/EventProducer/interface/FamosManager.h @@ -4,7 +4,6 @@ #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" #include -#include "FastSimulation/Particle/interface/ParticleTable.h" namespace HepMC { class GenEvent; diff --git a/FastSimulation/EventProducer/src/FamosManager.cc b/FastSimulation/EventProducer/src/FamosManager.cc index 4bdd640489596..1432114c97f45 100644 --- a/FastSimulation/EventProducer/src/FamosManager.cc +++ b/FastSimulation/EventProducer/src/FamosManager.cc @@ -32,7 +32,6 @@ #include "FastSimulation/TrajectoryManager/interface/TrajectoryManager.h" #include "FastSimulation/Event/interface/FSimEvent.h" #include "FastSimulation/ParticlePropagator/interface/MagneticFieldMap.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" #include "FastSimulation/Calorimetry/interface/CalorimetryManager.h" #include "FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h" #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" diff --git a/FastSimulation/EventProducer/src/FamosProducer.cc b/FastSimulation/EventProducer/src/FamosProducer.cc index 38d29799b7b24..553be2b946b67 100644 --- a/FastSimulation/EventProducer/src/FamosProducer.cc +++ b/FastSimulation/EventProducer/src/FamosProducer.cc @@ -62,7 +62,6 @@ FamosProducer::beginRun(edm::Run const& run, const edm::EventSetup & es) { void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es) { - ParticleTable::Sentry ptable(famosManager_->simEvent()->theTable()); using namespace edm; RandomEngineAndDistribution random(iEvent.streamID()); diff --git a/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc b/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc index 3ef16a65ade19..81e4b87d2b5d9 100755 --- a/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc +++ b/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc @@ -1,5 +1,6 @@ //FAMOS Headers #include "FastSimulation/MaterialEffects/interface/BremsstrahlungSimulator.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" #include @@ -21,12 +22,12 @@ BremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDi // This case corresponds to an electron entering the layer parallel to // the layer axis - no reliable simulation can be done in that case... // 08/02/06 - pv: increase protection from 1 to 4 X0 for eta>4.8 region - // if ( radLengths > 1. ) Particle.SetXYZT(0.,0.,0.,0.); - if ( radLengths > 4. ) Particle.SetXYZT(0.,0.,0.,0.); + // if ( radLengths > 1. ) Particle.particle().setMomentum(0.,0.,0.,0.); + if ( radLengths > 4. ) Particle.particle().setMomentum(0.,0.,0.,0.); // Hard brem probability with a photon Energy above photonEnergy. - if (Particle.e()=1. || xmin <=0. ) return; double bremProba = radLengths * ( 4./3. * std::log(1./xmin) @@ -41,8 +42,8 @@ BremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDi if ( !nPhotons ) return; //Rotate to the lab frame - double chi = Particle.theta(); - double psi = Particle.phi(); + double chi = Particle.particle().theta(); + double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); @@ -50,16 +51,16 @@ BremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDi for ( unsigned int i=0; iflatShoot()*2*M_PI; // theta from universal distribution - const double theta = gbteth(pp.e(),emass,xp,random)*emass/pp.e(); + const double theta = gbteth(pp.particle().e(),emass,xp,random)*emass/pp.particle().e(); // Make momentum components double stheta = std::sin(theta); @@ -94,7 +95,7 @@ BremsstrahlungSimulator::brem(ParticlePropagator& pp, RandomEngineAndDistributio double sphi = std::sin(phi); double cphi = std::cos(phi); - return xp * pp.e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); + return xp * pp.particle().e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); } diff --git a/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc b/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc index 3f318dc7643cf..21e196d5e4949 100755 --- a/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc +++ b/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc @@ -31,19 +31,19 @@ EnergyLossSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistri // It replaces the buggy GEANT3 -> C++ former version. // Author : Patrick Janot - 8-Jan-2004 - double p2 = Particle.Vect().Mag2(); + double p2 = Particle.particle().Vect().Mag2(); double verySmallP2 = 0.0001; if (p2<=verySmallP2) { deltaP.SetXYZT(0.,0.,0.,0.); return; } - double m2 = Particle.mass() * Particle.mass(); + double m2 = Particle.particle().mass() * Particle.particle().mass(); double e2 = p2+m2; double beta2 = p2/e2; double gama2 = e2/m2; - double charge2 = Particle.charge() * Particle.charge(); + double charge2 = Particle.particle().charge() * Particle.particle().charge(); // Energy loss spread in GeV double eSpread = 0.1536E-3*charge2*(theZ()/theA())*rho()*thick/beta2; @@ -60,17 +60,17 @@ EnergyLossSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistri double dedx = mostProbableLoss + eSpread * theGenerator->landau(random); // Compute the new energy and momentum - double aBitAboveMass = Particle.mass()*1.0001; - double newE = std::max(aBitAboveMass,Particle.e()-dedx); - // double newE = std::max(Particle.mass(),Particle.e()-dedx); + double aBitAboveMass = Particle.particle().mass()*1.0001; + double newE = std::max(aBitAboveMass,Particle.particle().e()-dedx); + // double newE = std::max(Particle.particle().mass(),Particle.particle().e()-dedx); double fac = std::sqrt((newE*newE-m2)/p2); // Update the momentum - deltaP.SetXYZT(Particle.Px()*(1.-fac),Particle.Py()*(1.-fac), - Particle.Pz()*(1.-fac),Particle.E()-newE); - Particle.SetXYZT(Particle.Px()*fac,Particle.Py()*fac, - Particle.Pz()*fac,newE); + deltaP.SetXYZT(Particle.particle().Px()*(1.-fac),Particle.particle().Py()*(1.-fac), + Particle.particle().Pz()*(1.-fac),Particle.particle().E()-newE); + Particle.particle().setMomentum(Particle.particle().Px()*fac,Particle.particle().Py()*fac, + Particle.particle().Pz()*fac,newE); } diff --git a/FastSimulation/MaterialEffects/src/MaterialEffects.cc b/FastSimulation/MaterialEffects/src/MaterialEffects.cc index 9d854046f42e6..a338499eea0b2 100755 --- a/FastSimulation/MaterialEffects/src/MaterialEffects.cc +++ b/FastSimulation/MaterialEffects/src/MaterialEffects.cc @@ -248,14 +248,14 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, // Photon Conversion //------------------- - if ( PairProduction && myTrack.pid()==22 ) { + if ( PairProduction && myTrack.particle().pid()==22 ) { // PairProduction->updateState(myTrack, radlen, random); if ( PairProduction->nDaughters() ) { //add a vertex to the mother particle - int ivertex = mySimEvent.addSimVertex(myTrack.vertex(),itrack, + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, FSimVertexType::PAIR_VERTEX); // Check if it is a valid vertex first: @@ -279,14 +279,14 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, } - if ( myTrack.pid() == 22 ) return; + if ( myTrack.particle().pid() == 22 ) return; //------------------------ // Nuclear interactions //------------------------ - if ( NuclearInteraction && abs(myTrack.pid()) > 100 - && abs(myTrack.pid()) < 1000000) { + if ( NuclearInteraction && abs(myTrack.particle().pid()) > 100 + && abs(myTrack.particle().pid()) < 1000000) { // Simulate a nuclear interaction double factor = 1.0; @@ -301,7 +301,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, if ( NuclearInteraction->nDaughters() ) { //add a end vertex to the mother particle - int ivertex = mySimEvent.addSimVertex(myTrack.vertex(),itrack, + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, FSimVertexType::NUCL_VERTEX); //std::cout << "ivertex= " << ivertex << " nDaughters= " // << NuclearInteraction->nDaughters() << std::endl; @@ -334,7 +334,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, } - if ( myTrack.charge() == 0 ) return; + if ( myTrack.particle().charge() == 0 ) return; if ( !MuonBremsstrahlung && !Bremsstrahlung && !EnergyLoss && !MultipleScattering ) return; @@ -342,7 +342,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, // Bremsstrahlung //---------------- - if ( Bremsstrahlung && abs(myTrack.pid())==11 ) { + if ( Bremsstrahlung && abs(myTrack.particle().pid())==11 ) { Bremsstrahlung->updateState(myTrack,radlen, random); @@ -350,7 +350,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, // Add a vertex, but do not attach it to the electron, because it // continues its way... - int ivertex = mySimEvent.addSimVertex(myTrack.vertex(),itrack, + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, FSimVertexType::BREM_VERTEX); // Check if it is a valid vertex first: @@ -373,7 +373,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, // Muon_Bremsstrahlung //-------------------------- - if ( MuonBremsstrahlung && abs(myTrack.pid())==13 ) { + if ( MuonBremsstrahlung && abs(myTrack.particle().pid())==13 ) { MuonBremsstrahlung->updateState(myTrack, radlen, random); @@ -381,7 +381,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, // Add a vertex, but do not attach it to the muon, because it // continues its way... - int ivertex = mySimEvent.addSimVertex(myTrack.vertex(),itrack, + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, FSimVertexType::BREM_VERTEX); // Check if it is a valid vertex first: @@ -406,9 +406,9 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, if ( EnergyLoss ) { - theEnergyLoss = myTrack.E(); + theEnergyLoss = myTrack.particle().E(); EnergyLoss->updateState(myTrack, radlen, random); - theEnergyLoss -= myTrack.E(); + theEnergyLoss -= myTrack.particle().E(); } @@ -416,7 +416,7 @@ void MaterialEffects::interact(FSimEvent& mySimEvent, //// Multiple scattering ///----------------------- - if ( MultipleScattering && myTrack.Pt() > pTmin ) { + if ( MultipleScattering && myTrack.particle().Pt() > pTmin ) { // MultipleScattering->setNormalVector(normalVector(layer,myTrack)); MultipleScattering->setNormalVector(theNormalVector); MultipleScattering->updateState(myTrack,radlen, random); @@ -431,7 +431,7 @@ MaterialEffects::radLengths(const TrackerLayer& layer, // Thickness of layer theThickness = layer.surface().mediumProperties().radLen(); - GlobalVector P(myTrack.Px(),myTrack.Py(),myTrack.Pz()); + GlobalVector P(myTrack.particle().Px(),myTrack.particle().Py(),myTrack.particle().Pz()); // Effective length of track inside layer (considering crossing angle) // double radlen = theThickness / fabs(P.dot(theNormalVector)/(P.mag()*theNormalVector.mag())); @@ -439,8 +439,8 @@ MaterialEffects::radLengths(const TrackerLayer& layer, // This is a series of fudge factors (from the geometry description), // to describe the layer inhomogeneities (services, cables, supports...) - double rad = myTrack.R(); - double zed = fabs(myTrack.Z()); + double rad = myTrack.particle().R(); + double zed = fabs(myTrack.particle().Z()); double factor = 1; @@ -470,7 +470,7 @@ MaterialEffects::normalVector(const TrackerLayer& layer, ParticlePropagator& myTrack ) const { return layer.forward() ? layer.disk()->normalVector() : - GlobalVector(myTrack.X(),myTrack.Y(),0.)/myTrack.R(); + GlobalVector(myTrack.particle().X(),myTrack.particle().Y(),0.)/myTrack.particle().R(); } void diff --git a/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc b/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc index f97e36c88fd4c..09c8332909777 100755 --- a/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc +++ b/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc @@ -13,15 +13,15 @@ MultipleScatteringSimulator::MultipleScatteringSimulator( void MultipleScatteringSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistribution const* random) { - double p2 = Particle.Vect().Mag2(); - double m2 = Particle.mass()*Particle.mass(); + double p2 = Particle.particle().Vect().Mag2(); + double m2 = Particle.particle().mass()*Particle.particle().mass(); double e = std::sqrt(p2+m2); double pbeta = p2/e; // This is p*beta // Average multiple scattering angle from Moliere radius // The sqrt(2) factor is because of the *space* angle - double theta0 = 0.0136 / pbeta * Particle.charge() + double theta0 = 0.0136 / pbeta * Particle.particle().charge() * std::sqrt(2.*radLengths) * (1. + 0.038*std::log(radLengths)); @@ -30,11 +30,11 @@ void MultipleScatteringSimulator::compute(ParticlePropagator &Particle, RandomEn // Plus a random rotation angle around the particle motion double phi = 2. * 3.14159265358979323 * random->flatShoot(); // The two rotations - RawParticle::Rotation rotation1(orthogonal(Particle.Vect()),theta); - RawParticle::Rotation rotation2(Particle.Vect(),phi); + RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()),theta); + RawParticle::Rotation rotation2(Particle.particle().Vect(),phi); // Rotate! - Particle.rotate(rotation1); - Particle.rotate(rotation2); + Particle.particle().rotate(rotation1); + Particle.particle().rotate(rotation2); // Generate mutiple scattering displacements in cm (assuming the detectors // are silicon only to determine the thickness) in the directions orthogonal @@ -52,7 +52,7 @@ void MultipleScatteringSimulator::compute(ParticlePropagator &Particle, RandomEn // The total displacement XYZVector delta = xp*tangent + yp*normal.Cross(tangent); // Translate! - Particle.translate(delta); + Particle.particle().translate(delta); } diff --git a/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc b/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc index 17dfc6f382b74..d267bd855f07c 100644 --- a/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc +++ b/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc @@ -8,6 +8,7 @@ #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FastSimulation/MaterialEffects/interface/PetrukhinModel.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include #include @@ -40,18 +41,18 @@ MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineA double NA = 6.022e+23; //Avogadro's number if ( radLengths > 4. ) { - Particle.SetXYZT(0.,0.,0.,0.); + Particle.particle().setMomentum(0.,0.,0.,0.); deltaPMuon.SetXYZT(0.,0.,0.,0.); brem_photon.SetXYZT(0.,0.,0.,0.); } // Hard brem probability with a photon Energy above photonEnergy. - double EMuon = Particle.e();//Muon Energy + double EMuon = Particle.particle().e();//Muon Energy if (EMuon=1. || xmin <=0. ) return; xmax = 1.; @@ -78,8 +79,8 @@ MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineA if ( !nPhotons ) return; //Rotate to the lab frame - double chi = Particle.theta(); - double psi = Particle.phi(); + double chi = Particle.particle().theta(); + double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); @@ -89,7 +90,7 @@ MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineA for ( unsigned int i=0; i " << xmin << std::endl; LogDebug("MuonBremsstrahlungSimulator")<< "Atomic Weight-> " << A << std::endl; @@ -102,7 +103,7 @@ MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineA LogDebug("MuonBremsstrahlungSimulator")<< " radLengths-> " << radLengths << std::endl; // Add a photon - RawParticle thePhoton(22,brem(Particle, random)); + RawParticle thePhoton=makeParticle(Particle.particleDataTable(),22,brem(Particle, random)); if (thePhoton.E()>0.){ thePhoton.rotate(rotY); @@ -111,7 +112,7 @@ MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineA _theUpdatedState.push_back(thePhoton); // Update the original mu +/- - deltaPMuon = Particle -= thePhoton.momentum(); + deltaPMuon = Particle.particle().momentum() -= thePhoton.momentum(); // Information of brem photon brem_photon.SetXYZT(thePhoton.Px(),thePhoton.Py(),thePhoton.Pz(),thePhoton.E()); @@ -153,7 +154,7 @@ MuonBremsstrahlungSimulator::brem(ParticlePropagator& pp, RandomEngineAndDistrib // Isotropic in phi const double phi = random->flatShoot()*2*M_PI; // theta from universal distribution - const double theta = gbteth(pp.e(),mumass,xp,random)*mumass/pp.e(); + const double theta = gbteth(pp.particle().e(),mumass,xp,random)*mumass/pp.particle().e(); // Make momentum components double stheta = std::sin(theta); @@ -161,7 +162,7 @@ MuonBremsstrahlungSimulator::brem(ParticlePropagator& pp, RandomEngineAndDistrib double sphi = std::sin(phi); double cphi = std::cos(phi); - return xp * pp.e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); + return xp * pp.particle().e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc b/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc index 7a99667c0733a..ed577c26bac14 100644 --- a/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc +++ b/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc @@ -10,6 +10,7 @@ #include "FastSimulation/MaterialEffects/interface/CMSDummyDeexcitation.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" #include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h" +#include "FastSimulation/Particle/interface/makeParticle.h" // Geant4 headers #include "G4ParticleDefinition.hh" @@ -181,7 +182,7 @@ NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator( theDiffuseElastic = new G4DiffuseElastic(); // Geant4 particles and cross sections - std::call_once(initializeOnce, [this] () { + std::call_once(initializeOnce, [] () { theG4Hadron[0] = G4Proton::Proton(); theG4Hadron[1] = G4Neutron::Neutron(); theG4Hadron[2] = G4PionPlus::PionPlus(); @@ -254,10 +255,10 @@ NuclearInteractionFTFSimulator::~NuclearInteractionFTFSimulator() { void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { - //std::cout << "#### Primary " << Particle.pid() << " E(GeV)= " - // << Particle.momentum().e() << std::endl; + //std::cout << "#### Primary " << Particle.particle().pid() << " E(GeV)= " + // << Particle.particle().momentum().e() << std::endl; - int thePid = Particle.pid(); + int thePid = Particle.particle().pid(); if(thePid != theId[currIdx]) { currParticle = nullptr; currIdx = 0; @@ -277,7 +278,7 @@ void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, // fill projectile for Geant4 double mass = currParticle->GetPDGMass(); - double ekin = CLHEP::GeV*Particle.momentum().e() - mass; + double ekin = CLHEP::GeV*Particle.particle().momentum().e() - mass; // check interaction length intLengthElastic = nuclElLength[currIdx]; @@ -313,9 +314,9 @@ void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, if (currInteractionLength > radLengths) { return; } // fill projectile for Geant4 - double px = Particle.momentum().px(); - double py = Particle.momentum().py(); - double pz = Particle.momentum().pz(); + double px = Particle.particle().momentum().px(); + double py = Particle.particle().momentum().py(); + double pz = Particle.particle().momentum().pz(); double ptot = sqrt(px*px + py*py + pz*pz); double norm = 1./ptot; G4ThreeVector dir(px*norm, py*norm, pz*norm); @@ -342,13 +343,13 @@ void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, double cost = (dir*dirnew); double sint = std::sqrt((1. - cost)*(1. + cost)); - curr4Mom.set(ptot*dirnew.x(),ptot*dirnew.y(),ptot*dirnew.z(),Particle.momentum().e()); + curr4Mom.set(ptot*dirnew.x(),ptot*dirnew.y(),ptot*dirnew.z(),Particle.particle().momentum().e()); // Always create a daughter if the kink is large engough if (sint > theDistCut) { saveDaughter(Particle, curr4Mom, thePid); } else { - Particle.SetXYZT(curr4Mom.px(), curr4Mom.py(), curr4Mom.pz(), curr4Mom.e()); + Particle.particle().setMomentum(curr4Mom.px(), curr4Mom.py(), curr4Mom.pz(), curr4Mom.e()); } // inelastic interaction @@ -420,12 +421,13 @@ void NuclearInteractionFTFSimulator::saveDaughter(ParticlePropagator& Particle, const G4LorentzVector& lv, int pdgid) { unsigned int idx = _theUpdatedState.size(); - _theUpdatedState.push_back(Particle); - _theUpdatedState[idx].SetXYZT(lv.px()*fact,lv.py()*fact,lv.pz()*fact,lv.e()*fact); - _theUpdatedState[idx].setID(pdgid); + _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), + pdgid, + XYZTLorentzVector{lv.px()*fact,lv.py()*fact,lv.pz()*fact,lv.e()*fact}, + Particle.particle().vertex())); // Store the closest daughter index (for later tracking purposes, so charged particles only) - double distance = distanceToPrimary(Particle,_theUpdatedState[idx]); + double distance = distanceToPrimary(Particle.particle(),_theUpdatedState[idx]); // Find the closest daughter, if closer than a given upper limit. if ( distance < distMin && distance < theDistCut ) { distMin = distance; diff --git a/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc b/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc index 6c7b3eb59ee6c..c437d2a2f39e2 100644 --- a/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc +++ b/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc @@ -3,6 +3,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FastSimulation/MaterialEffects/interface/NuclearInteractionSimulator.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" #include "FastSimDataFormats/NuclearInteractions/interface/NUEvent.h" @@ -216,16 +217,16 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn // Read a Nuclear Interaction in a random manner - double pHadron = std::sqrt(Particle.Vect().Mag2()); + double pHadron = std::sqrt(Particle.particle().Vect().Mag2()); // htot->Fill(pHadron); // The hadron has enough momentum to create some relevant final state if ( pHadron > thePionEnergy ) { // The particle type - std::map::const_iterator thePit = theIDMap.find(Particle.pid()); + std::map::const_iterator thePit = theIDMap.find(Particle.particle().pid()); - int thePid = thePit != theIDMap.end() ? thePit->second : Particle.pid(); + int thePid = thePit != theIDMap.end() ? thePit->second : Particle.particle().pid(); // Is this particle type foreseen? unsigned fPid = abs(thePid); @@ -262,27 +263,26 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn // helas->Fill(pHadron); // Characteristic scattering angle for the elastic part - double theta0 = std::sqrt(3.)/ std::pow(theA(),1./3.) * Particle.mass()/pHadron; + double theta0 = std::sqrt(3.)/ std::pow(theA(),1./3.) * Particle.particle().mass()/pHadron; // Draw an angle with theta/theta0*exp[(-theta/2theta0)**2] shape double theta = theta0 * std::sqrt(-2.*std::log(random->flatShoot())); double phi = 2. * 3.14159265358979323 * random->flatShoot(); // Rotate the particle accordingly - RawParticle::Rotation rotation1(orthogonal(Particle.Vect()),theta); - RawParticle::Rotation rotation2(Particle.Vect(),phi); - Particle.rotate(rotation1); - Particle.rotate(rotation2); + RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()),theta); + RawParticle::Rotation rotation2(Particle.particle().Vect(),phi); + Particle.particle().rotate(rotation1); + Particle.particle().rotate(rotation2); // Distance double distance = std::sin(theta); // Create a daughter if the kink is large engough if ( distance > theDistCut ) { - _theUpdatedState.resize(1); - _theUpdatedState[0].SetXYZT(Particle.Px(), Particle.Py(), - Particle.Pz(), Particle.E()); - _theUpdatedState[0].setID(Particle.pid()); + _theUpdatedState.reserve(1); + _theUpdatedState.clear(); + _theUpdatedState.emplace_back(Particle.particle()); } // hscatter->Fill(myTheta); @@ -304,7 +304,7 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn // The smallest momentum for inelastic interactions double pMin = thePionPMin[thePidIndex]; // The correspong smallest four vector - XYZTLorentzVector Hadron0(0.,0.,pMin,std::sqrt(pMin*pMin+Particle.M2())); + XYZTLorentzVector Hadron0(0.,0.,pMin,std::sqrt(pMin*pMin+Particle.particle().M2())); // The current centre-of-mass energy double ecm = (Proton+Hadron).M(); @@ -428,8 +428,9 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn unsigned lastTrack = anInteraction.last; // std::cout << "First and last tracks are " << firstTrack << " " << lastTrack << std::endl; - _theUpdatedState.resize(lastTrack-firstTrack+1); - + _theUpdatedState.reserve(lastTrack-firstTrack+1); + _theUpdatedState.clear(); + double distMin = 1E99; // Some rotation around the boost axis, for more randomness @@ -467,11 +468,11 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn + aParticle.pz*aParticle.pz + aParticle.mass*aParticle.mass/(ecm*ecm) ); - RawParticle& aDaughter = _theUpdatedState[idaugh]; - aDaughter.SetXYZT(aParticle.px*ecm,aParticle.py*ecm, - aParticle.pz*ecm,energy*ecm); - aDaughter.setID(aParticle.id); - + RawParticle& aDaughter = _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), + aParticle.id, + XYZTLorentzVector( + aParticle.px*ecm,aParticle.py*ecm, + aParticle.pz*ecm,energy*ecm))); // Rotate to the collision axis aDaughter.rotate(orthRotation); @@ -482,7 +483,7 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn aDaughter.boost(axisBoost); // Store the closest daughter index (for later tracking purposes, so charged particles only) - double distance = distanceToPrimary(Particle,aDaughter); + double distance = distanceToPrimary(Particle.particle(),aDaughter); // Find the closest daughter, if closer than a given upper limit. if ( distance < distMin && distance < theDistCut ) { distMin = distance; @@ -515,9 +516,10 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn elastic > 1.- (inelastic4*theInelasticLength) /theTotalInteractionLength ) { // A fake particle with 0 momentum as a daughter! - _theUpdatedState.resize(1); - _theUpdatedState[0].SetXYZT(0.,0.,0.,0.); - _theUpdatedState[0].setID(22); + _theUpdatedState.reserve(1); + _theUpdatedState.clear(); + _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), + 22, XYZTLorentzVector(0.,0.,0.,0.))); } } diff --git a/FastSimulation/MaterialEffects/src/PairProductionSimulator.cc b/FastSimulation/MaterialEffects/src/PairProductionSimulator.cc index 0c193065f806a..14e1945f225c3 100644 --- a/FastSimulation/MaterialEffects/src/PairProductionSimulator.cc +++ b/FastSimulation/MaterialEffects/src/PairProductionSimulator.cc @@ -1,5 +1,6 @@ #include "FastSimulation/MaterialEffects/interface/PairProductionSimulator.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include @@ -13,7 +14,7 @@ void PairProductionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { - double eGamma = Particle.e(); + double eGamma = Particle.particle().e(); // The photon has enough energy to create a pair if ( eGamma>=photonEnergy ) { @@ -65,28 +66,31 @@ PairProductionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDi } - double chi = Particle.theta(); - double psi = Particle.phi(); + double chi = Particle.particle().theta(); + double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); - _theUpdatedState.resize(2,RawParticle()); + _theUpdatedState.reserve(2); + _theUpdatedState.clear(); - // The eletron - _theUpdatedState[0].SetXYZT(pElectron*stheta1*cphi, - pElectron*stheta1*sphi, - pElectron*ctheta1, - eElectron); - _theUpdatedState[0].setID(+11); + // The electron + _theUpdatedState.emplace_back( + makeParticle(Particle.particleDataTable(), + +11,XYZTLorentzVector(pElectron*stheta1*cphi, + pElectron*stheta1*sphi, + pElectron*ctheta1, + eElectron) )); _theUpdatedState[0].rotate(rotY); _theUpdatedState[0].rotate(rotZ); // The positron - _theUpdatedState[1].SetXYZT(-pPositron*stheta2*cphi, - -pPositron*stheta2*sphi, - pPositron*ctheta2, - ePositron); - _theUpdatedState[1].setID(-11); + _theUpdatedState.emplace_back( + makeParticle(Particle.particleDataTable(), + -11,XYZTLorentzVector(-pPositron*stheta2*cphi, + -pPositron*stheta2*sphi, + pPositron*ctheta2, + ePositron))); _theUpdatedState[1].rotate(rotY); _theUpdatedState[1].rotate(rotZ); diff --git a/FastSimulation/MaterialEffects/test/testMaterialEffects.cc b/FastSimulation/MaterialEffects/test/testMaterialEffects.cc index c4edd2c7f4824..e96c9858de3de 100644 --- a/FastSimulation/MaterialEffects/test/testMaterialEffects.cc +++ b/FastSimulation/MaterialEffects/test/testMaterialEffects.cc @@ -12,7 +12,6 @@ #include "FastSimulation/Event/interface/FSimEvent.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimVertex.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" #include "DQMServices/Core/interface/MonitorElement.h" @@ -665,8 +664,6 @@ void testMaterialEffects::dqmBeginRun(edm::Run const&, edm::EventSetup const& es void testMaterialEffects::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - ParticleTable::Sentry(mySimEvent[0]->theTable()); - if( ( nevt < 100 && nevt%10 == 0) || ( nevt < 1000 && nevt%100 == 0) || nevt%1000 == 0 ) diff --git a/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc b/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc index 15acbf1301abe..86da2ede57feb 100644 --- a/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc +++ b/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc @@ -14,7 +14,6 @@ #include "FastSimulation/Event/interface/FSimEvent.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimVertex.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" #include "FastSimDataFormats/NuclearInteractions/interface/NUEvent.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" @@ -738,8 +737,6 @@ void testNuclearInteractions::dqmBeginRun(edm::Run const&, const edm::EventSetup void testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - ParticleTable::Sentry ptable(mySimEvent[0]->theTable()); - ++totalNEvt; if ( totalNEvt/1000*1000 == totalNEvt ) std::cout << "Number of event analysed/NU " diff --git a/FastSimulation/MuonSimHitProducer/interface/MuonSimHitProducer.h b/FastSimulation/MuonSimHitProducer/interface/MuonSimHitProducer.h index 9665cdf7c7285..79d2fc9f6bba8 100644 --- a/FastSimulation/MuonSimHitProducer/interface/MuonSimHitProducer.h +++ b/FastSimulation/MuonSimHitProducer/interface/MuonSimHitProducer.h @@ -25,6 +25,7 @@ // user include files #include "FWCore/Framework/interface/stream/EDProducer.h" #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" // FastSimulation headers class MagneticField; @@ -91,7 +92,8 @@ class MuonSimHitProducer : public edm::stream::EDProducer <> { void applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, TrajectoryStateOnSurface& tsos, double radPath, - RandomEngineAndDistribution const*); + RandomEngineAndDistribution const*, + HepPDT::ParticleDataTable const&); // ----------- parameters ---------------------------- diff --git a/FastSimulation/MuonSimHitProducer/src/MuonSimHitProducer.cc b/FastSimulation/MuonSimHitProducer/src/MuonSimHitProducer.cc index b760966b4a63c..973d37719d8c7 100644 --- a/FastSimulation/MuonSimHitProducer/src/MuonSimHitProducer.cc +++ b/FastSimulation/MuonSimHitProducer/src/MuonSimHitProducer.cc @@ -56,9 +56,6 @@ #include "DataFormats/GeometrySurface/interface/PlaneBuilder.h" #include "DataFormats/GeometrySurface/interface/TangentPlane.h" -// for particle table -#include "FastSimulation/Particle/interface/ParticleTable.h" - //////////////////////////////////////////////////////////////////////////// // Geometry, Magnetic Field #include "Geometry/DTGeometry/interface/DTGeometry.h" @@ -157,7 +154,6 @@ MuonSimHitProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup) { // using namespace std; edm::ESHandle < HepPDT::ParticleDataTable > pdg; iSetup.getData(pdg); - ParticleTable::Sentry ptable(pdg.product()); RandomEngineAndDistribution random(iEvent.streamID()); @@ -315,7 +311,7 @@ MuonSimHitProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup) { // Insert dE/dx fluctuations and multiple scattering // Skip this step if nextNoMaterial.first is not valid // This happens rarely (~0.02% of ttbar events) - if ( theMaterialEffects && nextNoMaterial.first.isValid() ) applyMaterialEffects(propagatedState, nextNoMaterial.first, radPath, &random); + if ( theMaterialEffects && nextNoMaterial.first.isValid() ) applyMaterialEffects(propagatedState, nextNoMaterial.first, radPath, &random, *pdg); // Check that the 'shaken' propagatedState is still valid, otherwise continue if ( !propagatedState.isValid() ) continue; // (No evidence that this ever happens) @@ -573,7 +569,8 @@ void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, TrajectoryStateOnSurface& tsos, double radPath, - RandomEngineAndDistribution const* random) { + RandomEngineAndDistribution const* random, + HepPDT::ParticleDataTable const& table) { // The energy loss simulator EnergyLossSimulator* energyLoss = theMaterialEffects->energyLossSimulator(); @@ -596,8 +593,7 @@ MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, XYZTLorentzVector position(gPos.x(),gPos.y(),gPos.z(),0.); XYZTLorentzVector momentum(gMom.x(),gMom.y(),gMom.z(),en); float charge = (float)(tsos.charge()); - ParticlePropagator theMuon(momentum,position,charge,nullptr); - theMuon.setID(-(int)charge*13); + ParticlePropagator theMuon(rawparticle::makeMuon(charge<1.,momentum,position),nullptr,nullptr,&table); // Recompute the energy loss to get the fluctuations if ( energyLoss ) { @@ -622,13 +618,13 @@ MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, double fac = energyLoss->deltaMom().E()/energyLoss->mostLikelyLoss(); // Particle momentum & position after energy loss + fluctuation - XYZTLorentzVector theNewMomentum = theMuon.momentum() + energyLoss->deltaMom() + fac * deltaMom; - XYZTLorentzVector theNewPosition = theMuon.vertex() + fac * deltaPos; + XYZTLorentzVector theNewMomentum = theMuon.particle().momentum() + energyLoss->deltaMom() + fac * deltaMom; + XYZTLorentzVector theNewPosition = theMuon.particle().vertex() + fac * deltaPos; fac = (theNewMomentum.E()*theNewMomentum.E()-mu*mu)/theNewMomentum.Vect().Mag2(); fac = fac>0.? std::sqrt(fac) : 1E-9; - theMuon.SetXYZT(theNewMomentum.Px()*fac,theNewMomentum.Py()*fac, + theMuon.particle().setMomentum(theNewMomentum.Px()*fac,theNewMomentum.Py()*fac, theNewMomentum.Pz()*fac,theNewMomentum.E()); - theMuon.setVertex(theNewPosition); + theMuon.particle().setVertex(theNewPosition); } @@ -649,8 +645,8 @@ MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, // Fill the propagated state - GlobalPoint propagatedPosition(theMuon.X(),theMuon.Y(),theMuon.Z()); - GlobalVector propagatedMomentum(theMuon.Px(),theMuon.Py(),theMuon.Pz()); + GlobalPoint propagatedPosition(theMuon.particle().X(),theMuon.particle().Y(),theMuon.particle().Z()); + GlobalVector propagatedMomentum(theMuon.particle().Px(),theMuon.particle().Py(),theMuon.particle().Pz()); GlobalTrajectoryParameters propagatedGtp(propagatedPosition,propagatedMomentum,(int)charge,magfield); tsosWithdEdx = TrajectoryStateOnSurface(propagatedGtp,nextSurface); diff --git a/FastSimulation/Particle/BuildFile.xml b/FastSimulation/Particle/BuildFile.xml index 4b1bd5ca81f83..d9667bff5de9f 100644 --- a/FastSimulation/Particle/BuildFile.xml +++ b/FastSimulation/Particle/BuildFile.xml @@ -1,5 +1,6 @@ + diff --git a/FastSimulation/Particle/interface/ParticleTable.h b/FastSimulation/Particle/interface/ParticleTable.h deleted file mode 100644 index b2c05691e43aa..0000000000000 --- a/FastSimulation/Particle/interface/ParticleTable.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef FastSimulation_Particle_ParticleTable_H -#define FastSimulation_Particle_ParticleTable_H - -// HepPDT header -#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" -#include - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -class ParticleTable { - -public: - struct Sentry{ - Sentry(const HepPDT::ParticleDataTable* pdt) { - ParticleTable::instance()->set(pdt); - } - ~Sentry() { - ParticleTable::instance()->set(nullptr); - } - }; - - ~ParticleTable() { - } - - /// Get the pointer to the particle data table - const HepPDT::ParticleDataTable* theTable() const { - return pdt_; - } - - static ParticleTable* const instance() { - if( !myself ) myself = new ParticleTable(); - return myself; - } - -private: - - ParticleTable(const HepPDT::ParticleDataTable* pdt=nullptr) : pdt_(pdt) {} - void set( const HepPDT::ParticleDataTable* pdt) { pdt_ = pdt; } - static thread_local ParticleTable* myself; - - const HepPDT::ParticleDataTable* pdt_; - - friend struct Sentry; -}; - - - -#endif // FastSimulation_Particle_ParticleTable_H diff --git a/FastSimulation/Particle/interface/makeParticle.h b/FastSimulation/Particle/interface/makeParticle.h new file mode 100644 index 0000000000000..7301fb5033304 --- /dev/null +++ b/FastSimulation/Particle/interface/makeParticle.h @@ -0,0 +1,33 @@ +#ifndef FastSimulation_Particle_makeParticle_h +#define FastSimulation_Particle_makeParticle_h +// -*- C++ -*- +// +// Package: FastSimulation/Particle +// Class : makeParticle +// +/**\class makeParticle makeParticle.h "FastSimulation/Particle/interface/makeParticle.h" + + Description: functions to create RawParticle from PDG ids + + Usage: + + +*/ +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 17:15:34 GMT +// + +// system include files +#include "DataFormats/Math/interface/LorentzVector.h" +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +// user include files + +// forward declarations +class RawParticle; + +RawParticle makeParticle(HepPDT::ParticleDataTable const*, int id, const math::XYZTLorentzVector& p); +RawParticle makeParticle(HepPDT::ParticleDataTable const*, int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart); + +#endif diff --git a/FastSimulation/Particle/interface/pdg_functions.h b/FastSimulation/Particle/interface/pdg_functions.h new file mode 100644 index 0000000000000..dfa69b02bf26b --- /dev/null +++ b/FastSimulation/Particle/interface/pdg_functions.h @@ -0,0 +1,38 @@ +#ifndef FastSimulation_Particle_pdg_functions_h +#define FastSimulation_Particle_pdg_functions_h +// -*- C++ -*- +// +// Package: FastSimulation/Particle +// Class : pdg_functions +// +/**\class pdg_functions pdg_functions.h "FastSimulation/Particle/interface/pdg_functions.h" + + Description: [one line class summary] + + Usage: + + +*/ +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 19:49:58 GMT +// + +// system include files +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +// user include files + +// forward declarations + +namespace pdg +{ + constexpr static double kInvalidMass = -99999; + double mass(int pdgID, const HepPDT::ParticleDataTable* pdt); + + constexpr static double kInvalidCtau = 1E99; + double cTau(int pdgID, const HepPDT::ParticleDataTable* pdt); +} + + +#endif diff --git a/FastSimulation/Particle/src/ParticleTable.cc b/FastSimulation/Particle/src/ParticleTable.cc deleted file mode 100644 index 3d3d530e2c312..0000000000000 --- a/FastSimulation/Particle/src/ParticleTable.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "FastSimulation/Particle/interface/ParticleTable.h" - -thread_local ParticleTable* ParticleTable::myself = nullptr; - diff --git a/FastSimulation/Particle/src/RawParticle.cc b/FastSimulation/Particle/src/RawParticle.cc deleted file mode 100644 index 56417b278cfd1..0000000000000 --- a/FastSimulation/Particle/src/RawParticle.cc +++ /dev/null @@ -1,315 +0,0 @@ -// ----------------------------------------------------------------------------- -// Prototype for a particle class -// ----------------------------------------------------------------------------- -// $Date: 2007/09/07 16:46:22 $ -// $Revision: 1.13 $ -// ----------------------------------------------------------------------------- -// Author: Stephan Wynhoff - RWTH-Aachen (Email: Stephan.Wynhoff@cern.ch) -// ----------------------------------------------------------------------------- -#include "FastSimulation/Particle/interface/ParticleTable.h" -#include "FastSimulation/Particle/interface/RawParticle.h" - -#include -#include -#include - -//using namespace HepPDT; - -RawParticle::RawParticle(): - tab( ParticleTable::instance() ) { - init(); -} - -RawParticle::RawParticle(const XYZTLorentzVector& p) - : XYZTLorentzVector(p), tab( ParticleTable::instance() ) { - init(); -} - -RawParticle::RawParticle(const int id, - const XYZTLorentzVector& p) - : XYZTLorentzVector(p), tab( ParticleTable::instance() ) { - this->init(); - this->setID(id); -} - -RawParticle::RawParticle(const std::string name, - const XYZTLorentzVector& p) - : XYZTLorentzVector(p), tab( ParticleTable::instance() ) { - this->init(); - this->setID(name); -} - -RawParticle::RawParticle(const XYZTLorentzVector& p, - const XYZTLorentzVector& xStart) : - XYZTLorentzVector(p), tab( ParticleTable::instance() ) -{ - init(); - myVertex = xStart; -} - -RawParticle::RawParticle(double px, double py, double pz, double e) : - XYZTLorentzVector(px,py,pz,e), tab( ParticleTable::instance() ) -{ - init(); -} - -RawParticle::RawParticle(const RawParticle &right) : - XYZTLorentzVector(right.Px(),right.Py(),right.Pz(),right.E()), - tab( ParticleTable::instance() ) -{ - myId = right.myId; - myStatus = right.myStatus; - myUsed = right.myUsed; - myCharge = right.myCharge; - myMass = right.myMass; - myVertex = (right.myVertex); - myInfo = (right.myInfo); -} - -RawParticle::~RawParticle() { - // nParticles--; -} - -RawParticle& -RawParticle::operator = (const RawParticle & right ) { - // cout << "Copy assignment " << endl; - if (this != &right) { // don't copy into yourself - this->SetXYZT(right.Px(),right.Py(),right.Pz(),right.E()); - myId = right.myId; - myStatus = right.myStatus; - myUsed = right.myUsed; - myCharge = right.myCharge; - myMass = right.myMass; - myVertex = right.myVertex; - tab = ParticleTable::instance(); - myInfo = right.myInfo; - } - return *this; -} - -void -RawParticle::init() { - myId=0; - myStatus=99; - myUsed=0; - myCharge=0.; - myMass=0.; - //tab = ParticleTable::instance(); - myInfo=nullptr; -} - -void -RawParticle::setID(const int id) { - myId = id; - if ( tab ) { - if ( !myInfo ) - myInfo = tab->theTable()->particle(HepPDT::ParticleID(myId)); - if ( myInfo ) { - myCharge = myInfo->charge(); - myMass = myInfo->mass().value(); - } - } -} - -void -RawParticle::setID(const std::string name) { - if ( tab ) { - if ( !myInfo ) myInfo = tab->theTable()->particle(name); - if ( myInfo ) { - myId = myInfo->pid(); - myCharge = myInfo->charge(); - myMass = myInfo->mass().value(); - } else { - myId = 0; - } - } -} - -void -RawParticle::setStatus(int istat) { - myStatus = istat; -} - -void -RawParticle::setMass(float m) { - myMass = m; -} - -void -RawParticle::setCharge(float q) { - myCharge = q; -} - -void -RawParticle::chargeConjugate() { - myId = -myId; - myCharge = -1*myCharge; -} - -void -RawParticle::setT(const double t) { - myVertex.SetE(t); -} - -void -RawParticle::rotate(double angle, const XYZVector& raxis) { - Rotation r(raxis,angle); - XYZVector v(r * Vect()); - SetXYZT(v.X(),v.Y(),v.Z(),E()); -} - -void -RawParticle::rotateX(double rphi) { - RotationX r(rphi); - XYZVector v(r * Vect()); - SetXYZT(v.X(),v.Y(),v.Z(),E()); -} - -void -RawParticle::rotateY(double rphi) { - RotationY r(rphi); - XYZVector v(r * Vect()); - SetXYZT(v.X(),v.Y(),v.Z(),E()); -} - -void -RawParticle::rotateZ(double rphi) { - RotationZ r(rphi); - XYZVector v(r * Vect()); - SetXYZT(v.X(),v.Y(),v.Z(),E()); -} - -void -RawParticle::boost(double betax, double betay, double betaz) { - Boost b(betax,betay,betaz); - XYZTLorentzVector p ( b * momentum() ); - SetXYZT(p.X(),p.Y(),p.Z(),p.T()); -} - -std::string RawParticle::PDGname() const { - std::string MyParticleName; - if ( tab && myInfo ) { - MyParticleName = myInfo->name(); - } else { - MyParticleName = "unknown "; - } - return (std::string) MyParticleName;} - - -void -RawParticle::printName() const { - std::string MyParticleName = PDGname(); - if (MyParticleName.length() != 0) { - std::cout << MyParticleName; - for(unsigned int k=0;k<9-MyParticleName.length() && k<10; k++) - std::cout << " " ; - } else { - std::cout << "unknown "; - } -} - -void -RawParticle::print() const { - printName(); - std::cout << std::setw(3) << status(); - std::cout.setf(std::ios::fixed, std::ios::floatfield); - std::cout.setf(std::ios::right, std::ios::adjustfield); - std::cout << std::setw(8) << std::setprecision(2) << Px(); - std::cout << std::setw(8) << std::setprecision(2) << Py(); - std::cout << std::setw(8) << std::setprecision(2) << Pz(); - std::cout << std::setw(8) << std::setprecision(2) << E(); - std::cout << std::setw(8) << std::setprecision(2) << M(); - std::cout << std::setw(8) << std::setprecision(2) << mass(); - std::cout << std::setw(8) << std::setprecision(2) << charge(); - std::cout << std::setw(8) << std::setprecision(2) << X(); - std::cout << std::setw(8) << std::setprecision(2) << Y(); - std::cout << std::setw(8) << std::setprecision(2) << Z(); - std::cout << std::setw(8) << std::setprecision(2) << T(); - std::cout << std::setw(0) << std::endl; -} - -std::ostream& operator <<(std::ostream& o , const RawParticle& p) { - - o.setf(std::ios::fixed, std::ios::floatfield); - o.setf(std::ios::right, std::ios::adjustfield); - - - o << std::setw(4) << std::setprecision(2) << p.pid() << " ("; - o << std::setw(2) << std::setprecision(2) << p.status() << "): "; - o << std::setw(10) << std::setprecision(4) << p.momentum() << " "; - o << std::setw(10) << std::setprecision(4) << p.vertex(); - return o; - -} - -double -RawParticle::PDGcharge() const { - double q=-99999; - if ( myInfo ) { - q=myInfo->charge(); - } - return q; -} - -double -RawParticle::PDGmass() const { - double m=-99999; - if ( myInfo ) { - m = myInfo->mass().value(); - } - return m; -} - -double -RawParticle::PDGcTau() const { - double ct=1E99; - if ( myInfo ) { - - // The lifetime is 0. in the Pythia Particle Data Table ! - // ct=tab->theTable()->particle(ParticleID(myId))->lifetime().value(); - - // Get it from the width (apparently Gamma/c!) - double w = myInfo->totalWidth().value(); - if ( w != 0. && myId != 1000022 ) { - ct = 6.582119e-25 / w / 10.; // ctau in cm - } else { - // Temporary fix of a bug in the particle data table - unsigned amyId = abs(myId); - if ( amyId != 22 && // photon - amyId != 11 && // e+/- - amyId != 10 && // nu_e - amyId != 12 && // nu_mu - amyId != 14 && // nu_tau - amyId != 1000022 && // Neutralino - amyId != 1000039 && // Gravitino - amyId != 2112 && // neutron/anti-neutron - amyId != 2212 && // proton/anti-proton - amyId != 101 && // Deutreron etc.. - amyId != 102 && // Deutreron etc.. - amyId != 103 && // Deutreron etc.. - amyId != 104 ) { // Deutreron etc.. - ct = 0.; - /* */ - } - } - } - - /* - std::cout << setw(20) << setprecision(18) - << "myId/ctau/width = " << myId << " " - << ct << " " << w << endl; - */ - - return ct; -} - -double -RawParticle::et() const { - double mypp, tmpEt=-1.; - - mypp = std::sqrt(momentum().mag2()); - if ( mypp != 0 ) { - tmpEt = E() * pt() / mypp; - } - return tmpEt; -} diff --git a/FastSimulation/Particle/src/makeParticle.cc b/FastSimulation/Particle/src/makeParticle.cc new file mode 100644 index 0000000000000..87377b8672183 --- /dev/null +++ b/FastSimulation/Particle/src/makeParticle.cc @@ -0,0 +1,52 @@ +// -*- C++ -*- +// +// Package: FastSimulation/Particle +// Class : makeParticle +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 17:15:41 GMT +// + +// system include files + +// user include files +#include "FastSimulation/Particle/interface/makeParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" + + +inline RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, double mass, double charge) { + return RawParticle(id,p,mass, charge); +} + +inline RawParticle unchecked_makeParticle(int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart, double mass, double charge) { + return RawParticle(id,p, xStart, mass, charge); +} + + +RawParticle makeParticle(HepPDT::ParticleDataTable const* table, int id, const math::XYZTLorentzVector& p) { + double charge =0.; + double mass = 0.; + auto info = table->particle(HepPDT::ParticleID(id)); + if ( info ) { + charge = info->charge(); + mass = info->mass().value(); + } + + return unchecked_makeParticle(id,p,mass, charge); +} + +RawParticle makeParticle(HepPDT::ParticleDataTable const* table, int id, const math::XYZTLorentzVector& p, const math::XYZTLorentzVector& xStart) { + double charge =0.; + double mass = 0.; + auto info = table->particle(HepPDT::ParticleID(id)); + if ( info ) { + charge = info->charge(); + mass = info->mass().value(); + } + return unchecked_makeParticle(id, p, xStart, mass, charge); +} + + diff --git a/FastSimulation/Particle/src/pdg_functions.cc b/FastSimulation/Particle/src/pdg_functions.cc new file mode 100644 index 0000000000000..9ff429bb093ba --- /dev/null +++ b/FastSimulation/Particle/src/pdg_functions.cc @@ -0,0 +1,68 @@ +// -*- C++ -*- +// +// Package: FastSimulation/Particle +// Class : pdg_functions +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Mon, 04 Mar 2019 19:53:06 GMT +// + +// system include files + +// user include files +#include "FastSimulation/Particle/interface/pdg_functions.h" + +double +pdg::mass(int pdgID, HepPDT::ParticleDataTable const* theTable) { + auto info = theTable->particle(HepPDT::ParticleID(pdgID)); + if(info) { + return info->mass().value(); + } + return kInvalidMass; +} + +double +pdg::cTau(int pdgID, HepPDT::ParticleDataTable const* theTable) { + auto info = theTable->particle(HepPDT::ParticleID(pdgID)); + double ct = kInvalidCtau; + if (info) { + // The lifetime is 0. in the Pythia Particle Data Table ! + // ct=tab->theTable()->particle(ParticleID(myId))->lifetime().value(); + + // Get it from the width (apparently Gamma/c!) + double w = info->totalWidth().value(); + if ( w != 0. && pdgID != 1000022 ) { + ct = 6.582119e-25 / w / 10.; // ctau in cm + } else { + // Temporary fix of a bug in the particle data table + unsigned amyId = abs(pdgID); + if ( amyId != 22 && // photon + amyId != 11 && // e+/- + amyId != 10 && // nu_e + amyId != 12 && // nu_mu + amyId != 14 && // nu_tau + amyId != 1000022 && // Neutralino + amyId != 1000039 && // Gravitino + amyId != 2112 && // neutron/anti-neutron + amyId != 2212 && // proton/anti-proton + amyId != 101 && // Deutreron etc.. + amyId != 102 && // Deutreron etc.. + amyId != 103 && // Deutreron etc.. + amyId != 104 ) { // Deutreron etc.. + ct = 0.; + /* */ + } + } + } + + /* + std::cout << setw(20) << setprecision(18) + << "myId/ctau/width = " << myId << " " + << ct << " " << w << endl; + */ + return ct; +} + diff --git a/FastSimulation/ParticleDecay/src/PythiaDecays.cc b/FastSimulation/ParticleDecay/src/PythiaDecays.cc index 7a459c31e9f06..9af3bdf26ed64 100644 --- a/FastSimulation/ParticleDecay/src/PythiaDecays.cc +++ b/FastSimulation/ParticleDecay/src/PythiaDecays.cc @@ -1,4 +1,5 @@ #include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include "FastSimulation/ParticleDecay/interface/PythiaDecays.h" #include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h" @@ -38,16 +39,16 @@ PythiaDecays::particleDaughters(ParticlePropagator& particle, CLHEP::HepRandomEn theList.clear(); // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc - int pid = particle.pid(); + int pid = particle.particle().pid(); decayer->event.reset(); Pythia8::Particle py8part( pid , 93, 0, 0, 0, 0, 0, 0, - particle.momentum().x(), // note: momentum().x() and Px() are the same - particle.momentum().y(), - particle.momentum().z(), - particle.momentum().t(), - particle.mass() ); - py8part.vProd( particle.X(), particle.Y(), - particle.Z(), particle.T() ); + particle.particle().momentum().x(), // note: momentum().x() and Px() are the same + particle.particle().momentum().y(), + particle.particle().momentum().z(), + particle.particle().momentum().t(), + particle.particle().mass() ); + py8part.vProd( particle.particle().X(), particle.particle().Y(), + particle.particle().Z(), particle.particle().T() ); decayer->event.append( py8part ); int nentries_before = decayer->event.size(); @@ -57,19 +58,23 @@ PythiaDecays::particleDaughters(ParticlePropagator& particle, CLHEP::HepRandomEn int nentries_after = decayer->event.size(); if ( nentries_after <= nentries_before ) return theList; - theList.resize(nentries_after - nentries_before,RawParticle()); + theList.reserve(nentries_after - nentries_before); for ( int ipart=nentries_before; ipartevent[ipart]; - theList[ipart-nentries_before].SetXYZT( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() ); - theList[ipart-nentries_before].setVertex( py8daughter.xProd(), - py8daughter.yProd(), - py8daughter.zProd(), - py8daughter.tProd() ); - theList[ipart-nentries_before].setID( py8daughter.id() ); - theList[ipart-nentries_before].setMass( py8daughter.m() ); + theList.emplace_back( + makeParticle(particle.particleDataTable(), + py8daughter.id(), + XYZTLorentzVector( py8daughter.px(), + py8daughter.py(), + py8daughter.pz(), + py8daughter.e() ), + XYZTLorentzVector( py8daughter.xProd(), + py8daughter.yProd(), + py8daughter.zProd(), + py8daughter.tProd() ) ) ).setMass( py8daughter.m() ); } return theList; diff --git a/FastSimulation/ParticlePropagator/BuildFile.xml b/FastSimulation/ParticlePropagator/BuildFile.xml index 2de8413a925c0..01e7214e959ab 100644 --- a/FastSimulation/ParticlePropagator/BuildFile.xml +++ b/FastSimulation/ParticlePropagator/BuildFile.xml @@ -1,7 +1,7 @@ - + diff --git a/FastSimulation/ParticlePropagator/interface/ParticlePropagator.h b/FastSimulation/ParticlePropagator/interface/ParticlePropagator.h index 24e66ee1f5fba..38efc5ed96966 100644 --- a/FastSimulation/ParticlePropagator/interface/ParticlePropagator.h +++ b/FastSimulation/ParticlePropagator/interface/ParticlePropagator.h @@ -17,7 +17,8 @@ * \version 15-Dec-2003 */ // FAMOS Headers -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" class TrackerLayer; class FSimTrack; @@ -36,37 +37,43 @@ class ParticlePropagator : public BaseParticlePropagator { ParticlePropagator(const RawParticle& myPart, double R, double Z, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine); + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table); /** Constructor with only a RawParticle as argument for subsequent propagation to known surfaces (ECAL, HCAL ...) */ ParticlePropagator(const RawParticle& myPart, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine); + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table); /** Constructor with two LorentzVector (momentum and vertex (in cm)) and an electric charge propagation to known surfaces (ECAL, HCAL ...) */ ParticlePropagator(const XYZTLorentzVector& p, const XYZTLorentzVector& v, float q, - const MagneticFieldMap* aFieldMap); + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table); /** Constructor with a LorentzVector (momentum), a Hep3Vector (vertex in cm) and an electric charge propagation to known surfaces (ECAL, HCAL ...) */ ParticlePropagator(const XYZTLorentzVector& p, const XYZVector& v, float q, - const MagneticFieldMap* aFieldMap); + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table); /** Constructor with a FSimTrack from the FSimEvent*/ ParticlePropagator(const FSimTrack& simTrack, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine); + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table); /** Constructor with a (Base)ParticlePropagator*/ ParticlePropagator(const ParticlePropagator& myPropPart); // ParticlePropagator(BaseParticlePropagator myPropPart); ParticlePropagator(const BaseParticlePropagator &myPropPart, - const MagneticFieldMap* aFieldMap); + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table); /**Initialize the proper decay time of the particle*/ void initProperDecayTime(); @@ -91,10 +98,12 @@ class ParticlePropagator : public BaseParticlePropagator { void setPropagationConditions(const TrackerLayer&, bool firstLoop=true); + const HepPDT::ParticleDataTable* particleDataTable() const { return theTable; } private: const MagneticFieldMap* theFieldMap; const RandomEngineAndDistribution* random; + const HepPDT::ParticleDataTable* theTable = nullptr; }; diff --git a/FastSimulation/ParticlePropagator/src/ParticlePropagator.cc b/FastSimulation/ParticlePropagator/src/ParticlePropagator.cc index 5a42f29e0983e..129f095d22ca4 100644 --- a/FastSimulation/ParticlePropagator/src/ParticlePropagator.cc +++ b/FastSimulation/ParticlePropagator/src/ParticlePropagator.cc @@ -8,6 +8,8 @@ #include "FastSimulation/TrackerSetup/interface/TrackerLayer.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimVertex.h" +#include "FastSimulation/Particle/interface/pdg_functions.h" +#include "FastSimulation/Particle/interface/makeParticle.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" ParticlePropagator::ParticlePropagator() : @@ -16,60 +18,70 @@ ParticlePropagator::ParticlePropagator() : ParticlePropagator::ParticlePropagator(const RawParticle& myPart, double RCyl, double ZCyl, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine) : + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table) : BaseParticlePropagator(myPart,RCyl,ZCyl,0.), theFieldMap(aFieldMap), - random(engine) + random(engine), + theTable(table) { - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); initProperDecayTime(); } ParticlePropagator::ParticlePropagator( const RawParticle& myPart, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine) : + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table) : BaseParticlePropagator(myPart,0.,0.,0.), theFieldMap(aFieldMap), - random(engine) + random(engine), + theTable(table) { - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); initProperDecayTime(); } ParticlePropagator::ParticlePropagator(const XYZTLorentzVector& mom, const XYZTLorentzVector& vert, float q, - const MagneticFieldMap* aFieldMap) : - BaseParticlePropagator(RawParticle(mom,vert),0.,0.,0.), + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table) : + BaseParticlePropagator(RawParticle(mom,vert,q),0.,0.,0.), theFieldMap(aFieldMap), - random(nullptr) + random(nullptr), + theTable(table) { - setCharge(q); - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); } ParticlePropagator::ParticlePropagator(const XYZTLorentzVector& mom, const XYZVector& vert, float q, - const MagneticFieldMap* aFieldMap) : + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table) : BaseParticlePropagator( - RawParticle(mom,XYZTLorentzVector(vert.X(),vert.Y(),vert.Z(),0.0)),0.,0.,0.), + RawParticle(mom,XYZTLorentzVector(vert.X(),vert.Y(),vert.Z(),0.0), q),0.,0.,0.), theFieldMap(aFieldMap), - random(nullptr) + random(nullptr), + theTable(table) { - setCharge(q); - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); } ParticlePropagator::ParticlePropagator(const FSimTrack& simTrack, const MagneticFieldMap* aFieldMap, - const RandomEngineAndDistribution* engine) : - BaseParticlePropagator(RawParticle(simTrack.type(),simTrack.momentum()), + const RandomEngineAndDistribution* engine, + const HepPDT::ParticleDataTable* table) : + BaseParticlePropagator(makeParticle(table, + simTrack.type(), + simTrack.momentum(), + simTrack.vertex().position()), 0.,0.,0.), theFieldMap(aFieldMap), - random(engine) + random(engine), + theTable(table) { - setVertex(simTrack.vertex().position()); - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); if ( simTrack.decayTime() < 0. ) { if ( simTrack.nDaughters() ) // This particle already decayed, don't decay it twice @@ -91,11 +103,13 @@ ParticlePropagator::ParticlePropagator(const ParticlePropagator& myPropPart) : } ParticlePropagator::ParticlePropagator(const BaseParticlePropagator& myPropPart, - const MagneticFieldMap* aFieldMap) : + const MagneticFieldMap* aFieldMap, + const HepPDT::ParticleDataTable* table) : BaseParticlePropagator(myPropPart), - theFieldMap(aFieldMap) + theFieldMap(aFieldMap), + theTable(table) { - setMagneticField(fieldMap(X(),Y(),Z())); + setMagneticField(fieldMap(particle().X(),particle().Y(),particle().Z())); } @@ -104,9 +118,9 @@ ParticlePropagator::initProperDecayTime() { // And this is the proper time at which the particle will decay double properDecayTime = - (pid()==0||pid()==22||abs(pid())==11||abs(pid())==2112||abs(pid())==2212|| + (particle().pid()==0||particle().pid()==22||abs(particle().pid())==11||abs(particle().pid())==2112||abs(particle().pid())==2212|| !random) ? - 1E99 : -PDGcTau() * std::log(random->flatShoot()); + 1E99 : -pdg::cTau(particle().pid(), theTable) * std::log(random->flatShoot()); this->setProperDecayTime(properDecayTime); @@ -127,7 +141,7 @@ ParticlePropagator::propagateToNominalVertex(const XYZTLorentzVector& v) { ParticlePropagator ParticlePropagator::propagated() const { - return ParticlePropagator(BaseParticlePropagator::propagated(),theFieldMap); + return ParticlePropagator(BaseParticlePropagator::propagated(),theFieldMap,theTable); } double @@ -135,7 +149,7 @@ ParticlePropagator::fieldMap(double xx,double yy, double zz) { // Arguments now passed in cm. // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z(); // Return a dummy value for neutral particles! - return charge() == 0.0 || theFieldMap == nullptr ? + return particle().charge() == 0.0 || theFieldMap == nullptr ? 4. : theFieldMap->inTeslaZ(GlobalPoint(xx,yy,zz)); } @@ -144,7 +158,7 @@ ParticlePropagator::fieldMap(const TrackerLayer& layer, double coord, int succes // Arguments now passed in cm. // return MagneticFieldMap::instance()->inTesla(GlobalPoint(xx/10.,yy/10.,zz/10.)).z(); // Return a dummy value for neutral particles! - return charge() == 0.0 || theFieldMap == nullptr ? + return particle().charge() == 0.0 || theFieldMap == nullptr ? 4. : theFieldMap->inTeslaZ(layer,coord,success); } @@ -170,14 +184,14 @@ ParticlePropagator::propagateToBoundSurface(const TrackerLayer& layer) { // Set the magnetic field at the new location (if succesfully propagated) if ( done && !hasDecayed() ) { if ( success == 2 ) - setMagneticField(fieldMap(layer,r(),success)); + setMagneticField(fieldMap(layer,particle().r(),success)); else if ( success == 1 ) - setMagneticField(fieldMap(layer,z(),success)); + setMagneticField(fieldMap(layer,particle().z(),success)); } // There is some real material here fiducial = !(!disk && success!=1) && - !( disk && (success!=2 || r() { void beginStream(edm::StreamID id) override; void produce(edm::Event&, const edm::EventSetup&) override; void endStream() override; - virtual FSimTrack createFSimTrack(fastsim::Particle* particle, fastsim::ParticleManager* particleManager); + virtual FSimTrack createFSimTrack(fastsim::Particle* particle, fastsim::ParticleManager* particleManager, HepPDT::ParticleDataTable const& particleTable); edm::EDGetTokenT genParticlesToken_; //!< Token to get the genParticles fastsim::Geometry geometry_; //!< The definition of the tracker according to python config @@ -181,7 +181,6 @@ FastSimProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // Get the particle data table (in case lifetime or charge of GenParticles not set) edm::ESHandle pdt; iSetup.getData(pdt); - ParticleTable::Sentry ptable(&(*pdt)); // Get the GenParticle collection edm::Handle genParticles; @@ -323,7 +322,7 @@ FastSimProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) LogDebug(MESSAGECATEGORY) << "\n moving particle to calorimetry: " << *particle; // create FSimTrack (this is the object the old propagation uses) - myFSimTracks.push_back(createFSimTrack(particle.get(), &particleManager)); + myFSimTracks.push_back(createFSimTrack(particle.get(), &particleManager, *pdt)); // particle was decayed if(!particle->isStable() && particle->remainingProperLifeTimeC() < 1E-10) { @@ -400,7 +399,7 @@ FastSimProducer::endStream() } FSimTrack -FastSimProducer::createFSimTrack(fastsim::Particle* particle, fastsim::ParticleManager* particleManager) +FastSimProducer::createFSimTrack(fastsim::Particle* particle, fastsim::ParticleManager* particleManager, HepPDT::ParticleDataTable const& particleTable) { FSimTrack myFSimTrack(particle->pdgId(), particleManager->getSimTrack(particle->simTrackIndex()).momentum(), @@ -434,8 +433,10 @@ FastSimProducer::createFSimTrack(fastsim::Particle* particle, fastsim::ParticleM // Define ParticlePropagators (RawParticle) needed for CalorimetryManager and save them ////////// - RawParticle PP(particle->pdgId(), particle->momentum()); - PP.setVertex(particle->position()); + RawParticle PP = makeParticle(&particleTable, + particle->pdgId(), + particle->momentum(), + particle->position()); // no material if(caloLayer->getThickness(particle->position(), particle->momentum()) < 1E-10) diff --git a/FastSimulation/Tracking/plugins/BuildFile.xml b/FastSimulation/Tracking/plugins/BuildFile.xml index d5512cbdec418..f243063846536 100644 --- a/FastSimulation/Tracking/plugins/BuildFile.xml +++ b/FastSimulation/Tracking/plugins/BuildFile.xml @@ -10,7 +10,7 @@ - + diff --git a/FastSimulation/Tracking/test/testGeneralTracks.cc b/FastSimulation/Tracking/test/testGeneralTracks.cc index bb683e85b3546..fe7b9079d3f22 100644 --- a/FastSimulation/Tracking/test/testGeneralTracks.cc +++ b/FastSimulation/Tracking/test/testGeneralTracks.cc @@ -21,7 +21,6 @@ #include "FastSimulation/Event/interface/FSimEvent.h" #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FSimVertex.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" //#include "FastSimulation/Tracking/interface/TrajectorySeedHitCandidate.h" #include "DQMServices/Core/interface/DQMEDAnalyzer.h" @@ -160,8 +159,6 @@ void testGeneralTracks::dqmBeginRun(edm::Run const&, edm::EventSetup const& es) void testGeneralTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup ) { - ParticleTable::Sentry ptable(mySimEvent[0]->theTable()); - ++totalNEvt; // std::cout << " >>>>>>>>> Analizying Event " << totalNEvt << "<<<<<<< " << std::endl; diff --git a/FastSimulation/TrajectoryManager/src/TrajectoryManager.cc b/FastSimulation/TrajectoryManager/src/TrajectoryManager.cc index d781213e09a46..7616c817047ed 100755 --- a/FastSimulation/TrajectoryManager/src/TrajectoryManager.cc +++ b/FastSimulation/TrajectoryManager/src/TrajectoryManager.cc @@ -28,6 +28,7 @@ #include "FastSimulation/Event/interface/FSimVertex.h" #include "FastSimulation/Event/interface/KineParticleFilter.h" #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" +#include "FastSimulation/Particle/interface/pdg_functions.h" //#include "FastSimulation/Utilities/interface/Histos.h" //#include "FastSimulation/Utilities/interface/FamosLooses.h" @@ -167,7 +168,7 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // Get the geometry elements cyliter = _theGeometry->cylinderBegin(); // Prepare the propagation - ParticlePropagator PP(mySimEvent->track(fsimi),_theFieldMap,random); + ParticlePropagator PP(mySimEvent->track(fsimi),_theFieldMap,random,mySimEvent->theTable()); //The real work starts here int success = 1; int sign = +1; @@ -190,8 +191,8 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // 08/02/06 - pv: increase protection from 0.99 (eta=2.9932) to 0.9998 (eta=4.9517) // to simulate material effects at large eta // if above 0.99: propagate to the last tracker cylinder where the material is concentrated! - double ppcos2T = PP.cos2Theta(); - double ppcos2V = PP.cos2ThetaV(); + double ppcos2T = PP.particle().cos2Theta(); + double ppcos2V = PP.particle().cos2ThetaV(); if(use_hardcoded){ if ( ( ppcos2T > 0.99 && ppcos2T < 0.9998 ) && ( cyl == 0 || ( ppcos2V > 0.99 && ppcos2V < 0.9998 ) ) ){ @@ -213,7 +214,7 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // Loop over the cylinders while ( cyliter != _theGeometry->cylinderEnd() && loop<100 && // No more than 100 loops - mySimEvent->track(fsimi).notYetToEndVertex(PP.vertex())) { // The particle decayed + mySimEvent->track(fsimi).notYetToEndVertex(PP.particle().vertex())) { // The particle decayed // Skip layers with no material (kept just for historical reasons) if ( cyliter->surface().mediumProperties().radLen() < 1E-10 ) { @@ -259,7 +260,7 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // The particle may have decayed on its way... in which the daughters // have to be added to the event record - if ( PP.hasDecayed() || (!mySimEvent->track(fsimi).nDaughters() && PP.PDGcTau()<1E-3 ) ) { + if ( PP.hasDecayed() || (!mySimEvent->track(fsimi).nDaughters() && pdg::cTau(PP.particle().pid(),mySimEvent->theTable())<1E-3 ) ) { updateWithDaughters(PP, fsimi, random); break; } @@ -274,22 +275,22 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist bool saveHit = ( (loop==0 && sign>0) || !firstLoop ) && // Save only first half loop - PP.charge()!=0. && // Consider only charged particles + PP.particle().charge()!=0. && // Consider only charged particles cyliter->sensitive() && // Consider only sensitive layers - PP.Perp2()>pTmin*pTmin; // Consider only pT > pTmin + PP.particle().Perp2()>pTmin*pTmin; // Consider only pT > pTmin // Material effects are simulated there if ( theMaterialEffects ) theMaterialEffects->interact(*mySimEvent,*cyliter,PP,fsimi, random); // There is a PP.setXYZT=(0,0,0,0) if bremss fails - saveHit &= PP.E()>1E-6; + saveHit &= PP.particle().E()>1E-6; if ( saveHit ) { // Consider only active layers if ( cyliter->sensitive() ) { // Add information to the FSimTrack (not yet available) - // myTrack.addSimHit(PP,layer); + // myTrack.addSimHit(PP.particle(),layer); // Return one or two (for overlap regions) PSimHits in the full // tracker geometry @@ -297,11 +298,11 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist createPSimHits(*cyliter, PP, thePSimHits[fsimi], fsimi,mySimEvent->track(fsimi).type(), tTopo); /* - myHistos->fill("h302",PP.X() ,PP.Y()); - if ( sin(PP.vertex().Phi()) > 0. ) - myHistos->fill("h303",PP.Z(),PP.R()); + myHistos->fill("h302",PP.particle().X() ,PP.particle().Y()); + if ( sin(PP.particle().vertex().Phi()) > 0. ) + myHistos->fill("h303",PP.particle().Z(),PP.particle().R()); else - myHistos->fill("h303",PP.Z(),-PP.R()); + myHistos->fill("h303",PP.Z(),-PP.particle().R()); */ } @@ -309,22 +310,22 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // Fill Histos (~poor man event display) /* - myHistos->fill("h300",PP.x(),PP.y()); - if ( sin(PP.vertex().phi()) > 0. ) - myHistos->fill("h301",PP.z(),sqrt(PP.vertex().Perp2())); + myHistos->fill("h300",PP.particle().x(),PP.particle().y()); + if ( sin(PP.particle().vertex().phi()) > 0. ) + myHistos->fill("h301",PP.particle().z(),sqrt(PP.particle().vertex().Perp2())); else - myHistos->fill("h301",PP.z(),-sqrt(PP.vertex().Perp2())); + myHistos->fill("h301",PP.particle().z(),-sqrt(PP.particle().vertex().Perp2())); */ //The particle may have lost its energy in the material - if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.vertex()) && - !mySimEvent->filter().acceptParticle(PP) ) - mySimEvent->addSimVertex(PP.vertex(),fsimi, FSimVertexType::END_VERTEX); + if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.particle().vertex()) && + !mySimEvent->filter().acceptParticle(PP.particle()) ) + mySimEvent->addSimVertex(PP.particle().vertex(),fsimi, FSimVertexType::END_VERTEX); } // Stop here if the particle has reached an end - if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.vertex()) ) { + if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.particle().vertex()) ) { // Otherwise increment the cylinder iterator // do { @@ -362,7 +363,7 @@ TrajectoryManager::reconstruct(const TrackerTopology *tTopo, RandomEngineAndDist // Propagate all particles without a end vertex to the Preshower, // theECAL and the HCAL. - if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.vertex()) ) + if ( mySimEvent->track(fsimi).notYetToEndVertex(PP.particle().vertex()) ) propagateToCalorimeters(PP, fsimi, random); } @@ -378,8 +379,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra FSimTrack& myTrack = mySimEvent->track(fsimi); // Set the position and momentum at the end of the tracker volume - myTrack.setTkPosition(PP.vertex().Vect()); - myTrack.setTkMomentum(PP.momentum()); + myTrack.setTkPosition(PP.particle().vertex().Vect()); + myTrack.setTkMomentum(PP.particle().momentum()); // Propagate to Preshower Layer 1 PP.propagateToPreshowerLayer1(false); @@ -387,8 +388,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra updateWithDaughters(PP, fsimi, random); return; } - if ( myTrack.notYetToEndVertex(PP.vertex()) && PP.getSuccess() > 0 ) - myTrack.setLayer1(PP,PP.getSuccess()); + if ( myTrack.notYetToEndVertex(PP.particle().vertex()) && PP.getSuccess() > 0 ) + myTrack.setLayer1(PP.particle(),PP.getSuccess()); // Propagate to Preshower Layer 2 PP.propagateToPreshowerLayer2(false); @@ -396,8 +397,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra updateWithDaughters(PP, fsimi, random); return; } - if ( myTrack.notYetToEndVertex(PP.vertex()) && PP.getSuccess() > 0 ) - myTrack.setLayer2(PP,PP.getSuccess()); + if ( myTrack.notYetToEndVertex(PP.particle().vertex()) && PP.getSuccess() > 0 ) + myTrack.setLayer2(PP.particle(),PP.getSuccess()); // Propagate to Ecal Endcap PP.propagateToEcalEntrance(false); @@ -405,8 +406,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra updateWithDaughters(PP, fsimi, random); return; } - if ( myTrack.notYetToEndVertex(PP.vertex()) ) - myTrack.setEcal(PP,PP.getSuccess()); + if ( myTrack.notYetToEndVertex(PP.particle().vertex()) ) + myTrack.setEcal(PP.particle(),PP.getSuccess()); // Propagate to HCAL entrance PP.propagateToHcalEntrance(false); @@ -414,8 +415,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra updateWithDaughters(PP,fsimi, random); return; } - if ( myTrack.notYetToEndVertex(PP.vertex()) ) - myTrack.setHcal(PP,PP.getSuccess()); + if ( myTrack.notYetToEndVertex(PP.particle().vertex()) ) + myTrack.setHcal(PP.particle(),PP.getSuccess()); // Propagate to VFCAL entrance PP.propagateToVFcalEntrance(false); @@ -423,8 +424,8 @@ TrajectoryManager::propagateToCalorimeters(ParticlePropagator& PP, int fsimi, Ra updateWithDaughters(PP,fsimi, random); return; } - if ( myTrack.notYetToEndVertex(PP.vertex()) ) - myTrack.setVFcal(PP,PP.getSuccess()); + if ( myTrack.notYetToEndVertex(PP.particle().vertex()) ) + myTrack.setVFcal(PP.particle(),PP.getSuccess()); } @@ -468,11 +469,11 @@ TrajectoryManager::updateWithDaughters(ParticlePropagator& PP, int fsimi, Random // Move the vertex unsigned vertexId = mySimEvent->track(fsimi).endVertex().id(); - mySimEvent->vertex(vertexId).setPosition(PP.vertex()); + mySimEvent->vertex(vertexId).setPosition(PP.particle().vertex()); // Before-propagation and after-propagation momentum and vertex position XYZTLorentzVector momentumBefore = mySimEvent->track(fsimi).momentum(); - const XYZTLorentzVector& momentumAfter = PP.momentum(); + const XYZTLorentzVector& momentumAfter = PP.particle().momentum(); double magBefore = std::sqrt(momentumBefore.Vect().mag2()); double magAfter = std::sqrt(momentumAfter.Vect().mag2()); // Rotation to be applied @@ -507,8 +508,8 @@ TrajectoryManager::updateWithDaughters(ParticlePropagator& PP, int fsimi, Random for ( ; daughter != daughters.end(); ++daughter) { int theDaughterId = mySimEvent->addSimTrack(&(*daughter), ivertex); // Find the closest charged daughter (if charged mother) - if ( PP.charge() * daughter->charge() > 1E-10 ) { - double dist = (daughter->Vect().Unit().Cross(PP.Vect().Unit())).R(); + if ( PP.particle().charge() * daughter->charge() > 1E-10 ) { + double dist = (daughter->Vect().Unit().Cross(PP.particle().Vect().Unit())).R(); if ( dist < distCut && dist < distMin ) { distMin = dist; theClosestChargedDaughterId = theDaughterId; @@ -565,7 +566,7 @@ TrajectoryManager::createPSimHits(const TrackerLayer& layer, // std::cout << "PP.Z() = " << PP.Z() << std::endl; typedef GeometricSearchDet::DetWithState DetWithState; - const DetLayer* tkLayer = detLayer(layer,PP.Z()); + const DetLayer* tkLayer = detLayer(layer,PP.particle().Z()); TrajectoryStateOnSurface trajState = makeTrajectoryState( tkLayer, PP, &mf); float thickness = theMaterialEffects ? theMaterialEffects->thickness() : 0.; @@ -591,11 +592,11 @@ TrajectoryManager::makeTrajectoryState( const DetLayer* layer, const ParticlePropagator& pp, const MagneticField* field) const { - GlobalPoint pos( pp.X(), pp.Y(), pp.Z()); - GlobalVector mom( pp.Px(), pp.Py(), pp.Pz()); + GlobalPoint pos( pp.particle().X(), pp.particle().Y(), pp.particle().Z()); + GlobalVector mom( pp.particle().Px(), pp.particle().Py(), pp.particle().Pz()); auto plane = layer->surface().tangentPlane(pos); return TrajectoryStateOnSurface - (GlobalTrajectoryParameters( pos, mom, TrackCharge( pp.charge()), field), *plane); + (GlobalTrajectoryParameters( pos, mom, TrackCharge( pp.particle().charge()), field), *plane); } void diff --git a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h index 7544a5c48da5d..6a4861f7ac270 100644 --- a/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h +++ b/Fireworks/Calo/interface/FWHeatmapProxyBuilderTemplate.h @@ -48,8 +48,8 @@ class FWHeatmapProxyBuilderTemplate : public FWSimpleProxyBuilder { protected: std::map hitmap; - static const uint8_t gradient_steps = 9; - const float gradient[3][gradient_steps] = { + static constexpr uint8_t gradient_steps = 9; + static constexpr uint8_t gradient[3][gradient_steps] = { {0.2082*255, 0.0592*255, 0.0780*255, 0.0232*255, 0.1802*255, 0.5301*255, 0.8186*255, 0.9956*255, 0.9764*255}, {0.1664*255, 0.3599*255, 0.5041*255, 0.6419*255, 0.7178*255, 0.7492*255, 0.7328*255, 0.7862*255, 0.9832*255}, {0.5293*255, 0.8684*255, 0.8385*255, 0.7914*255, 0.6425*255, 0.4662*255, 0.3499*255, 0.1968*255, 0.0539*255} diff --git a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc index 27859a719793e..17ccb78e8671f 100644 --- a/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc +++ b/Fireworks/Calo/plugins/FWCaloClusterProxyBuilder.cc @@ -2,7 +2,8 @@ #include "Fireworks/Core/interface/FWEventItem.h" #include "Fireworks/Core/interface/FWGeometry.h" #include "Fireworks/Core/interface/BuilderUtils.h" -#include "DataFormats/CaloRecHit/interface/CaloCluster.h" +#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" +#include "DataFormats/Common/interface/ValueMap.h" #include "TEveBoxSet.h" #include "TEveStraightLineSet.h" @@ -16,25 +17,71 @@ class FWCaloClusterProxyBuilder : public FWHeatmapProxyBuilderTemplate> TimeValueMapHandle; + double timeLowerBound, timeUpperBound; + long layer; + double saturation_energy; + bool heatmap; + bool z_plus; + bool z_minus; + bool enableTimeFilter; + FWCaloClusterProxyBuilder(const FWCaloClusterProxyBuilder &) = delete; // stop default const FWCaloClusterProxyBuilder &operator=(const FWCaloClusterProxyBuilder &) = delete; // stop default - + + void setItem(const FWEventItem *iItem) override; + + void build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) override; void build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) override; }; +void FWCaloClusterProxyBuilder::setItem(const FWEventItem *iItem) +{ + FWHeatmapProxyBuilderTemplate::setItem(iItem); + if (iItem) + { + iItem->getConfig()->assertParam("Cluster(0)/RecHit(1)", false); + iItem->getConfig()->assertParam("EnableTimeFilter", false); + iItem->getConfig()->assertParam("TimeLowerBound(ns)", 0.01, 0.0, 75.0); + iItem->getConfig()->assertParam("TimeUpperBound(ns)", 0.01, 0.0, 75.0); + } +} + +void FWCaloClusterProxyBuilder::build(const FWEventItem *iItem, TEveElementList *product, const FWViewContext *vc) +{ + iItem->getEvent()->getByLabel(edm::InputTag("hgcalLayerClusters", "timeLayerCluster"), TimeValueMapHandle); + if(TimeValueMapHandle.isValid()){ + timeLowerBound = std::min(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); + timeUpperBound = std::max(item()->getConfig()->value("TimeLowerBound(ns)"), item()->getConfig()->value("TimeUpperBound(ns)")); + } + else { + std::cerr << "Warning: couldn't locate 'timeLayerCluster' ValueMap in root file." << std::endl; + } + + layer = item()->getConfig()->value("Layer"); + saturation_energy = item()->getConfig()->value("EnergyCutOff"); + heatmap = item()->getConfig()->value("Heatmap"); + z_plus = item()->getConfig()->value("Z+"); + z_minus = item()->getConfig()->value("Z-"); + enableTimeFilter = item()->getConfig()->value("EnableTimeFilter"); + + FWHeatmapProxyBuilderTemplate::build(iItem, product, vc); +} + void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned int iIndex, TEveElement &oItemHolder, const FWViewContext *) { - const long layer = item()->getConfig()->value("Layer"); - const double saturation_energy = item()->getConfig()->value("EnergyCutOff"); - const bool heatmap = item()->getConfig()->value("Heatmap"); - const bool z_plus = item()->getConfig()->value("Z+"); - const bool z_minus = item()->getConfig()->value("Z-"); + if (enableTimeFilter && TimeValueMapHandle.isValid()) + { + const float time = TimeValueMapHandle->get(iIndex); + if (time < timeLowerBound || time > timeUpperBound) + return; + } std::vector> clusterDetIds = iData.hitsAndFractions(); bool h_hex(false); TEveBoxSet *hex_boxset = new TEveBoxSet(); - if(!heatmap) + if (!heatmap) hex_boxset->UseSingleColor(); hex_boxset->SetPickable(true); hex_boxset->Reset(TEveBoxSet::kBT_Hex, true, 64); @@ -42,7 +89,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i bool h_box(false); TEveBoxSet *boxset = new TEveBoxSet(); - if(!heatmap) + if (!heatmap) boxset->UseSingleColor(); boxset->SetPickable(true); boxset->Reset(TEveBoxSet::kBT_FreeBox, true, 64); @@ -61,7 +108,7 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i if (iData.algo() == 8 || (type >= 8 && type <= 10)) { - if(heatmap && hitmap.find(it->first) == hitmap.end()) + if (heatmap && hitmap.find(it->first) == hitmap.end()) continue; const bool z = (it->first >> 25) & 0x1; @@ -105,21 +152,24 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i } // seed - if(iData.seed().rawId() == it->first.rawId()){ + if (iData.seed().rawId() == it->first.rawId()) + { TEveStraightLineSet *marker = new TEveStraightLineSet; - marker->SetLineWidth( 1 ); + marker->SetLineWidth(1); // center of RecHit float center[3] = { - corners[0], corners[1], corners[2]+shapes[3]*0.5f - }; + corners[0], corners[1], corners[2] + shapes[3] * 0.5f}; - if (isScintillator){ + if (isScintillator) + { constexpr int offset = 9; center[0] = (corners[6] + corners[6 + offset]) / 2; center[1] = (corners[7] + corners[7 + offset]) / 2; - } else { + } + else + { float min[2] = {1e3f, 1e3f}; float max[2] = {-1e3f, -1e3f}; @@ -139,21 +189,21 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i // draw 3D cross const float crossScale = 1.0f + fmin(iData.energy(), 5.0f); marker->AddLine( - center[0]-crossScale, center[1], center[2], - center[0]+crossScale, center[1], center[2] - ); + center[0] - crossScale, center[1], center[2], + center[0] + crossScale, center[1], center[2]); marker->AddLine( - center[0], center[1]-crossScale, center[2], - center[0], center[1]+crossScale, center[2] - ); + center[0], center[1] - crossScale, center[2], + center[0], center[1] + crossScale, center[2]); marker->AddLine( - center[0], center[1], center[2]-crossScale, - center[0], center[1], center[2]+crossScale - ); + center[0], center[1], center[2] - crossScale, + center[0], center[1], center[2] + crossScale); oItemHolder.AddElement(marker); } + const float energy = fmin((item()->getConfig()->value("Cluster(0)/RecHit(1)") ? hitmap[it->first]->energy() : iData.energy()) / saturation_energy, 1.0f); + const uint8_t colorFactor = gradient_steps*energy; + // Scintillator if (isScintillator) { @@ -171,9 +221,11 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i pnts[(i * 3 + 2) + total_vertices] = corners[i * 3 + 2] + shapes[3]; } boxset->AddBox(&pnts[0]); - if(heatmap) { - const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f)); - boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); + if (heatmap) + { + energy ? + boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : + boxset->DigitColor(64, 64, 64); } h_box = true; @@ -188,9 +240,11 @@ void FWCaloClusterProxyBuilder::build(const reco::CaloCluster &iData, unsigned i float radius = fabs(corners[6] - corners[6 + offset]) / 2; hex_boxset->AddHex(TEveVector(centerX, centerY, corners[2]), radius, 90.0, shapes[3]); - if(heatmap) { - const uint8_t colorFactor = gradient_steps*(fmin(hitmap[it->first]->energy()/saturation_energy, 1.0f)); - hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]); + if (heatmap) + { + energy ? + hex_boxset->DigitColor(gradient[0][colorFactor], gradient[1][colorFactor], gradient[2][colorFactor]) : + hex_boxset->DigitColor(64, 64, 64); } h_hex = true; diff --git a/Fireworks/FWInterface/BuildFile.xml b/Fireworks/FWInterface/BuildFile.xml index 7949c0dd89e25..da15bbb606f65 100644 --- a/Fireworks/FWInterface/BuildFile.xml +++ b/Fireworks/FWInterface/BuildFile.xml @@ -15,6 +15,8 @@ + + diff --git a/GeneratorInterface/GenFilters/BuildFile.xml b/GeneratorInterface/GenFilters/BuildFile.xml index 27fc975d60ef4..01c67c0f8b07e 100644 --- a/GeneratorInterface/GenFilters/BuildFile.xml +++ b/GeneratorInterface/GenFilters/BuildFile.xml @@ -20,8 +20,7 @@ - - + diff --git a/GeneratorInterface/GenFilters/interface/BHFilter.h b/GeneratorInterface/GenFilters/interface/BHFilter.h index a5f0e2ae10c9f..1132b3625737d 100644 --- a/GeneratorInterface/GenFilters/interface/BHFilter.h +++ b/GeneratorInterface/GenFilters/interface/BHFilter.h @@ -10,7 +10,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" //#include "AnalysisExamples/SiStripDetectorPerformance/interface/CosmicGenFilter.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include #include diff --git a/GeneratorInterface/ReggeGribovPartonMCInterface/src/fileinpathwrapper.cc b/GeneratorInterface/ReggeGribovPartonMCInterface/src/fileinpathwrapper.cc deleted file mode 100644 index c8f20f18fe1ab..0000000000000 --- a/GeneratorInterface/ReggeGribovPartonMCInterface/src/fileinpathwrapper.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "FWCore/ParameterSet/interface/FileInPath.h" -#include -extern "C"{ - const char* getfullpathfromfip_(char* fipname){ - //std::cout << "getfullpathfromfip_ " << fipname << std::endl; - edm::FileInPath* fip = new edm::FileInPath(fipname); - return fip->fullPath().c_str(); - } -} diff --git a/Geometry/CMSCommonData/python/cmsExtendedGeometry2023D41XML_cfi.py b/Geometry/CMSCommonData/python/cmsExtendedGeometry2023D41XML_cfi.py new file mode 100644 index 0000000000000..260b4d9b6d59d --- /dev/null +++ b/Geometry/CMSCommonData/python/cmsExtendedGeometry2023D41XML_cfi.py @@ -0,0 +1,127 @@ +import FWCore.ParameterSet.Config as cms + +# This config was generated automatically using generate2023Geometry.py +# If you notice a mistake, please update the generating script, not just this config + +XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", + geomXMLFiles = cms.vstring( + 'Geometry/CMSCommonData/data/materials.xml', + 'Geometry/CMSCommonData/data/rotations.xml', + 'Geometry/CMSCommonData/data/extend/v2/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms/2023/v2/cms.xml', + 'Geometry/CMSCommonData/data/eta3/etaMax.xml', + 'Geometry/CMSCommonData/data/cmsMother.xml', + 'Geometry/CMSCommonData/data/cmsTracker.xml', + 'Geometry/CMSCommonData/data/caloBase/2023/v2/caloBase.xml', + 'Geometry/CMSCommonData/data/cmsCalo.xml', + 'Geometry/CMSCommonData/data/muonBase/2023/v2/muonBase.xml', + 'Geometry/CMSCommonData/data/cmsMuon.xml', + 'Geometry/CMSCommonData/data/mgnt.xml', + 'Geometry/CMSCommonData/data/beampipe/2023/v1/beampipe.xml', + 'Geometry/CMSCommonData/data/cmsBeam/2023/v1/cmsBeam.xml', + 'Geometry/CMSCommonData/data/muonMB.xml', + 'Geometry/CMSCommonData/data/muonMagnet.xml', + 'Geometry/CMSCommonData/data/cavern/2017/v2/cavern.xml', + 'Geometry/CMSCommonData/data/cavernData/2017/v1/cavernData.xml', + 'Geometry/CMSCommonData/data/cavernFloor/2017/v1/cavernFloor.xml', + 'Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml', + 'Geometry/TrackerCommonData/data/pixfwdCommon.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixfwd.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/pixbar.xml', + 'Geometry/TrackerCommonData/data/trackermaterial.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/otst.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/tracker.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixel.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerbar.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerfwd.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker404/trackerStructureTopology.xml', + 'Geometry/TrackerCommonData/data/PhaseII/TiltedTracker613/pixelStructureTopology.xml', + 'Geometry/TrackerSimData/data/PhaseII/TiltedTracker404/trackersens.xml', + 'Geometry/TrackerSimData/data/PhaseII/TiltedTracker404/pixelsens.xml', + 'Geometry/TrackerRecoData/data/PhaseII/TiltedTracker613/trackerRecoMaterial.xml', + 'Geometry/TrackerSimData/data/PhaseII/TiltedTracker404/trackerProdCuts.xml', + 'Geometry/TrackerSimData/data/PhaseII/TiltedTracker404/pixelProdCuts.xml', + 'Geometry/TrackerSimData/data/trackerProdCutsBEAM.xml', + 'Geometry/EcalCommonData/data/PhaseII/v2/eregalgo.xml', + 'Geometry/EcalCommonData/data/PhaseII/v2/ectkcable.xml', + 'Geometry/EcalCommonData/data/PhaseII/v2/ectkcablemat.xml', + 'Geometry/EcalCommonData/data/ebalgo.xml', + 'Geometry/EcalCommonData/data/ebcon.xml', + 'Geometry/EcalCommonData/data/ebrot.xml', + 'Geometry/HcalCommonData/data/hcalrotations.xml', + 'Geometry/HcalCommonData/data/hcal/v2/hcalalgo.xml', + 'Geometry/HcalCommonData/data/hcalbarrelalgo.xml', + 'Geometry/HcalCommonData/data/hcalcablealgo/v2/hcalcablealgo.xml', + 'Geometry/HcalCommonData/data/hcalouteralgo.xml', + 'Geometry/HcalCommonData/data/hcalforwardalgo.xml', + 'Geometry/HcalCommonData/data/hcalSimNumbering/NoHE/hcalSimNumbering.xml', + 'Geometry/HcalCommonData/data/hcalRecNumbering/NoHE/hcalRecNumbering.xml', + 'Geometry/HcalCommonData/data/average/hcalforwardmaterial.xml', + 'Geometry/HGCalCommonData/data/hgcalMaterial/v1/hgcalMaterial.xml', + 'Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml', + 'Geometry/HGCalCommonData/data/hgcalEE/v10/hgcalEE.xml', + 'Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml', + 'Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml', + 'Geometry/HGCalCommonData/data/hgcalwafer/v9/hgcalwafer.xml', + 'Geometry/HGCalCommonData/data/hgcalcell/v9/hgcalcell.xml', + 'Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml', + 'Geometry/MuonCommonData/data/mbCommon/2017/v2/mbCommon.xml', + 'Geometry/MuonCommonData/data/mb1/2015/v1/mb1.xml', + 'Geometry/MuonCommonData/data/mb2/2015/v1/mb2.xml', + 'Geometry/MuonCommonData/data/mb3/2015/v1/mb3.xml', + 'Geometry/MuonCommonData/data/mb4/2015/v1/mb4.xml', + 'Geometry/MuonCommonData/data/design/muonYoke.xml', + 'Geometry/MuonCommonData/data/mf/2023/v2/mf.xml', + 'Geometry/MuonCommonData/data/rpcf/2023/v1/rpcf.xml', + 'Geometry/MuonCommonData/data/gemf/TDR_BaseLine/gemf.xml', + 'Geometry/MuonCommonData/data/gem11/TDR_BaseLine/gem11.xml', + 'Geometry/MuonCommonData/data/gem21/TDR_Dev/gem21.xml', + 'Geometry/MuonCommonData/data/csc/2015/v1/csc.xml', + 'Geometry/MuonCommonData/data/mfshield/2023/v1/mfshield.xml', + 'Geometry/MuonCommonData/data/me0/TDR_Dev/me0.xml', + 'Geometry/ForwardCommonData/data/forwardshield/2017/v1/forwardshield.xml', + 'Geometry/ForwardCommonData/data/brmrotations.xml', + 'Geometry/ForwardCommonData/data/PostLS2/brm.xml', + 'Geometry/ForwardCommonData/data/zdcmaterials.xml', + 'Geometry/ForwardCommonData/data/lumimaterials.xml', + 'Geometry/ForwardCommonData/data/zdcrotations.xml', + 'Geometry/ForwardCommonData/data/lumirotations.xml', + 'Geometry/ForwardCommonData/data/zdc.xml', + 'Geometry/ForwardCommonData/data/zdclumi.xml', + 'Geometry/ForwardCommonData/data/cmszdc.xml', + 'Geometry/MTDCommonData/data/btl.xml', + 'Geometry/MTDCommonData/data/etl/v2/etl.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/v2/mtd.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdStructureTopology.xml', + 'Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml', + )+ + cms.vstring( + 'Geometry/MuonCommonData/data/muonNumbering/TDR_DeV/muonNumbering.xml', + 'Geometry/EcalSimData/data/PhaseII/ecalsens.xml', + 'Geometry/HcalCommonData/data/hcalsens/NoHE/hcalsenspmf.xml', + 'Geometry/HcalSimData/data/hf.xml', + 'Geometry/HcalSimData/data/hfpmt.xml', + 'Geometry/HcalSimData/data/hffibrebundle.xml', + 'Geometry/HcalSimData/data/CaloUtil.xml', + 'Geometry/HGCalSimData/data/hgcsensv9.xml', + 'Geometry/MuonSimData/data/PhaseII/ME0EtaPart/muonSens.xml', + 'Geometry/DTGeometryBuilder/data/dtSpecsFilter.xml', + 'Geometry/CSCGeometryBuilder/data/cscSpecsFilter.xml', + 'Geometry/CSCGeometryBuilder/data/cscSpecs.xml', + 'Geometry/RPCGeometryBuilder/data/2023/v1/RPCSpecs.xml', + 'Geometry/GEMGeometryBuilder/data/v7/GEMSpecsFilter.xml', + 'Geometry/GEMGeometryBuilder/data/v7/GEMSpecs.xml', + 'Geometry/ForwardCommonData/data/brmsens.xml', + 'Geometry/ForwardSimData/data/zdcsens.xml', + 'Geometry/MTDSimData/data/CrystalBarPhiFlat/mtdsens.xml', + 'Geometry/HcalSimData/data/HcalProdCuts.xml', + 'Geometry/EcalSimData/data/EcalProdCuts.xml', + 'Geometry/HGCalSimData/data/hgcProdCutsv9.xml', + 'Geometry/MuonSimData/data/PhaseII/muonProdCuts.xml', + 'Geometry/ForwardSimData/data/zdcProdCuts.xml', + 'Geometry/ForwardSimData/data/ForwardShieldProdCuts.xml', + 'Geometry/MTDSimData/data/CrystalBarPhiFlat/mtdProdCuts.xml', + 'Geometry/CMSCommonData/data/FieldParameters.xml', + ), + rootNodeName = cms.string('cms:OCMS') +) diff --git a/Geometry/DTGeometryBuilder/data/dtSpecsFilter/2019/v1/dtSpecsFilter.xml b/Geometry/DTGeometryBuilder/data/dtSpecsFilter/2019/v1/dtSpecsFilter.xml new file mode 100644 index 0000000000000..fdc2be9704343 --- /dev/null +++ b/Geometry/DTGeometryBuilder/data/dtSpecsFilter/2019/v1/dtSpecsFilter.xml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/ForwardCommonData/data/hfnose/v0/hfnose.xml b/Geometry/ForwardCommonData/data/hfnose/v0/hfnose.xml index 52685d14e05cd..9c477ebdedaf9 100644 --- a/Geometry/ForwardCommonData/data/hfnose/v0/hfnose.xml +++ b/Geometry/ForwardCommonData/data/hfnose/v0/hfnose.xml @@ -108,6 +108,8 @@ 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0 + + [HFNoseRMax3], 0, 0, 0, 0 diff --git a/Geometry/ForwardCommonData/data/hfnose/v1/hfnose.xml b/Geometry/ForwardCommonData/data/hfnose/v1/hfnose.xml index 4e851e6c58d09..e129cd6f17517 100644 --- a/Geometry/ForwardCommonData/data/hfnose/v1/hfnose.xml +++ b/Geometry/ForwardCommonData/data/hfnose/v1/hfnose.xml @@ -175,6 +175,8 @@ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0 + + [HFNoseRMax3], 0, 0, 0, 0 diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/ahcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/ahcal.xml index d1057e7f5e7cf..68cd5a1738097 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/ahcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/ahcal.xml @@ -2,21 +2,21 @@ - - - + + + - - - - + + + + - - + + @@ -106,43 +106,87 @@ - + ahcal:Steel235, materials:Air, ahcal:Steel235, ahcal:CFM, ahcal:PCB, - ahcal:Polystyrole, ahcal:Polystyrene, ahcal:Steel235, ahcal:Steel235 - - AHcalRadiator, AHcalAirGap, AHcalCassette, AHcalCable, AHcalPCB, - AHcalFoil, AHcalActive, AHcalAbsorber, AHcalAbsorberLastCover - + ahcal:Polystyrole, ahcal:Polystyrene, ahcal:Steel235, ahcal:Steel235, + materials:Air + + AHcalRadiator, AHcalAirGa1p, AHcalCassette, AHcalCable, AHcalPCB, + AHcalFoil, AHcalActive, AHcalAbsorber, AHcalAbsorberLastCover, + AHcalAirGap2 + [ahcal:radiatorThick], [ahcal:airgapThick], [ahcal:cassetteThick], [ahcal:cableThick], [ahcal:pcbThick], [ahcal:foilThick], - [ahcal:scintThick], [ahcal:absorberThick], 5.0*mm - - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11 - - 19.6*mm, 81.5*mm, 81.5*mm, 81.5*mm, 81.5*mm, 81.5*mm, 81.5*mm, 81.5*mm, - 81.5*mm, 81.5*mm, 81.5*mm, 86.5*mm - + [ahcal:scintThick], [ahcal:absorberThick], 5.0*mm, + 9.0*mm + + 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, + 20, 20, 20, 20, 4, + 12, 3 + + + 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, + 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, + 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, + 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, 52.4*mm, + 44.685*mm, 43.4*mm + + 7, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, - 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 8 + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, + 0, 9, 0, 9, + 0, 1, 2, 3, 4, 5, 6, 5, 2, 1, 0, 1, + 0, 9, 0 - + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0 [ahcal:passiveWidth], [ahcal:activeWidth] [ahcal:passiveHeight], [ahcal:activeHeight] - 12, 12 + 24, 24 [ahcal:tileGap], [ahcal:tileGap] diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/cms.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/cms.xml new file mode 100644 index 0000000000000..664de2bcb6fdb --- /dev/null +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/cms.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml index 061f4b042ddf6..14fc0964acb48 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcal.xml @@ -2,48 +2,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -58,6 +70,14 @@ + + + + + + + + @@ -130,6 +150,14 @@ + + + + + + + + @@ -162,26 +190,25 @@ - - + - + - + - + - + @@ -189,7 +216,7 @@ - + @@ -219,5 +246,11 @@ + + + + + + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalCons.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalCons.xml index f11800f6de7f7..1b3d99797549e 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalCons.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalCons.xml @@ -1,5 +1,5 @@ - + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml index 272bd1fe25e2f..2842f8188d1ad 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalEE.xml @@ -7,66 +7,72 @@ - + + - + + hgcalwafer:HGCalEEWaferFine, hgcalwafer:HGCalEEWaferCoarse - - hgcal:HGCalEEPCB, hgcal:HGCalEEKapton, hgcal:HGCalEEAbsorber, - hgcal:HGCalEECuAbsorber, hgcal:HGCalEEAbsorber48To63, - hgcal:HGCalEEAbsorber52To70, hgcal:HGCalEEAbsorber59To62, - hgcal:HGCalEEAbsorber68To74, hgcal:HGCalEECuKapton, + + hgcal:HGCalEESensitive, hgcal:HGCalEEPCB, + hgcal:HGCalEEKapton, hgcal:HGCalEEAbsorber, + hgcal:HGCalEECuAbsorber, hgcal:HGCalEEAbsorber48To63, + hgcal:HGCalEEAbsorber52To70, hgcal:HGCalEEAbsorber59To62, + hgcal:HGCalEEAbsorber68To74, hgcal:HGCalEECuKapton, hgcal:HGCalEECuPCB - - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:StainlessSteel, - materials:Lead,materials:Copper, materials:Air, - materials:Aluminium, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Iron, materials:Air, materials:Air, - materials:Air - - EEPCB, EEKapton, EECuWShield, - EECuShield, EECuWShield48To63, EECuWShield52To70, + + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:StainlessSteel, + materials:Lead, materials:Copper, materials:Air, + materials:Aluminium, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Iron, materials:Air, materials:Air, + materials:Air, materials:Aluminium + + EEPCB, EEKapton, EECuWShield, + EECuShield, EECuWShield48To63, EECuWShield52To70, EECuWShield59To62, EECuWShield68To74, EEFeAbsorber, - EEPbAbsorber, EECuHeatShield,EESensitive, - EEAlcase, EEgap1, EEgap2, - EEgap3, EEgap4, EEgap5, - EEgap6, EEgap7, EEgap8, - EEgap9, EEgap10, EEgap11, - EEFHAbs, EECuKapton, EECuPCB, - EEgap12 - - [hgcal:thPCB], [hgcal:thKapton], [hgcal:thAbsEE], - [hgcal:thAbsCuEE], [hgcal:thAbsEE48To63], [hgcal:thAbsEE52To70], + EEPbAbsorber, EECuHeatShield, EESensitive, + EEAlcase, EEgap1, EEgap2, + EEgap3, EEgap4, EEgap5, + EEgap6, EEgap7, EEgap8, + EEgap9, EEgap10, EEgap11, + EEFHAbs, EECuKapton, EECuPCB, + EEgap12, EEMCPAl + + [hgcal:thPCB], [hgcal:thKapton], [hgcal:thAbsEE], + [hgcal:thAbsCuEE], [hgcal:thAbsEE48To63], [hgcal:thAbsEE52To70], [hgcal:thAbsEE59To62], [hgcal:thAbsEE68To74], 0.3*mm, - 4.9*mm, 6.0*mm, 0.10*mm, - 2.1*mm, 3.095*mm, 3.145*mm, - 3.7*mm, 4.7*mm, 5.5*mm, - 6.7*mm, 7.7*mm, 8.7*mm, - 9.5*mm, 10.09*mm, 119.7*mm, - 40*mm, [hgcal:thCuKapton], [hgcal:thCuPCB], - 44*mm - - 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24, 3 - - 144.15*mm, 29.05*mm, 29.05*mm, - 30.05*mm, 30.05*mm, 30.05*mm, - 28.05*mm, 28.05*mm, 28.05*mm, - 28.05*mm, 32.25*mm, 35.05*mm, + 4.9*mm, 6.0*mm, [hgcal:thSilicon], + 2.1*mm, 3.095*mm, 3.145*mm, + 3.7*mm, 4.7*mm, 5.5*mm, + 6.7*mm, 7.7*mm, 8.7*mm, + 9.5*mm, 10.09*mm, 119.7*mm, + 40.0*mm, [hgcal:thCuKapton], [hgcal:thCuPCB], + 44.0*mm, 5.0*mm + + 149.15*mm, 29.05*mm, 29.05*mm, + 30.05*mm, 30.05*mm, 30.05*mm, + 28.05*mm, 28.05*mm, 28.05*mm, + 28.05*mm, 32.25*mm, 35.05*mm, 31.455*mm, 32.155*mm, 86.1*mm - - 12, 23, 8, 9, 8, 16, 0, 26, 11, 11, 11, 25, 1, 2, 10, 2, 1, 25, 11, 11, 11, 26, 0, + + + 0, 24, 46, 68, 90,112,134,156,178,200,222,246,270,294,318 + + 23, 45, 67, 89,111,133,155,177,199,221,245,269,293,317,320 + + 28, 12, 23, 8, 9, 8, 16, 0, 26, 11, 11, 11, 25, 1, 2, 10, 2, 1, 25, 11, 11, 11, 26, 0, 19, 8, 9, 8, 15, 0, 26, 11, 11, 11, 25, 1, 2, 10, 2, 1, 25, 11, 11, 11, 26, 0, 19, 8, 9, 8, 15, 0, 26, 11, 11, 11, 25, 1, 2, 10, 2, 1, 25, 11, 11, 11, 26, 0, 20, 8, 9, 8, 15, 0, 26, 11, 11, 11, 25, 1, 2, 10, 2, 1, 25, 11, 11, 11, 26, 0, @@ -81,9 +87,9 @@ 21, 8, 9, 8, 14, 0, 26, 11, 11, 11, 25, 1, 2, 4, 10, 5, 2, 1, 25, 11, 11, 11, 26, 0, 22, 8, 9, 8, 13, 0, 26, 11, 11, 11, 25, 1, 2, 6, 10, 7, 2, 1, 25, 11, 11, 11, 26, 0, 24, 27, 12 - - - 0, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 0, 4, 3, 10, 1, 1, 1, 11, 2, + + + 0, 0, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 0, 4, 3, 10, 1, 1, 1, 11, 2, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 0, 4, 3, 10, 1, 1, 1, 11, 2, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 0, 4, 3, 10, 1, 1, 1, 11, 2, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 0, 4, 3, 10, 1, 1, 1, 11, 2, @@ -98,23 +104,32 @@ 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 6, 0, 7, 4, 3, 10, 1, 1, 1, 11, 2, 0, 0, 0, 0, 0, 2, 11, 1, 1, 1, 10, 3, 4, 8, 0, 9, 4, 3, 10, 1, 1, 1, 11, 2, 0, 0, 0 - + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 + - - - 0.0, 0.0 - - 0, 0 - - [hgcal:zminEE], [hgcal:zmaxEE] - - [hgcal:rmaxEE], [hgcal:rmaxEE] - + + diff --git a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml index b24e2aa74429e..3bc53cfe108f4 100644 --- a/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml +++ b/Geometry/HGCalCommonData/data/TB181/Oct181/hgcalHE.xml @@ -8,90 +8,183 @@ + - + + hgcalwafer:HGCalHEWaferFine, hgcalwafer:HGCalHEWaferCoarse - - hgcal:HGCalHEPCB, hgcal:HGCalHEKapton, hgcal:HGCalHEAbsorber, - hgcal:HGCalHECuAbsorber, hgcal:HGCalHEPCBAbsorber, hgcal:HGCalHECuKapton, - hgcal:HGCalHECuPCB - - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:StainlessSteel, - materials:Copper, materials:Air, materials:StainlessSteel, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air, materials:Air, - materials:Air, materials:Air - - - HEPCB, HEKapton, HECuWShield, - HECuShield, HEPCBShield, HEFeAbsorber, + + hgcal:HGCalHESiliconSensitive, hgcal:HGCalHEPCB, + hgcal:HGCalHEKapton, hgcal:HGCalHEAbsorber, + hgcal:HGCalHECuAbsorber, hgcal:HGCalHEPCBAbsorber, + hgcal:HGCalHECuKapton, hgcal:HGCalHECuPCB + + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Iron, + materials:Copper, materials:Air, materials:Iron, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Iron, + materials:Copper, materials:Air, materials:Iron, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air, materials:Air, + materials:Air, materials:Air + + HEPCB, HEKapton, HECuWShield, + HECuShield, HEPCBShield, HEFeAbsorber, HECuHeatShield, HESiliconSensitive, HEFeBox, - HEAirGap1, HEAirGap2, HEAirGap3, - HEAirGap4, HEAirGap5, HEAirGap6, - HEAirGap7, HEAirGap8, HEAirGap9, - HEAirGap10, HEAirGap11, HEAirGap12, - HEAirGap13, HEAirGap14, HEAirGap15, - HEAirGap16, HEAirGap17, HEAirGap18, - HECuKapton, HECuPCB - - - [hgcal:thPCB], [hgcal:thKapton], [hgcal:thAbsHE], - [hgcal:thAbsCuHE], [hgcal:thAbsPCBHE], 41*mm, - 6.0*mm, 0.1*mm, 9*mm, - 0.7*mm, 2.8*mm, 3.8*mm, - 4.8*mm, 6.8*mm, 7.0*mm, - 8.0*mm, 13*mm, 14.0*mm, - 15.0*mm, 16*mm, 17*mm, - 18*mm, 19*mm, 20*mm, - 36*mm, 52*mm, 190*mm, - [hgcal:thCuKapton], [hgcal:thCuPCB] - - - 11, 12, 13, 13, 10, 15, 12, 13, 13, 12, 12, 14 - - 19.275*mm, 69.275*mm, 68.075*mm, - 69.075*mm, 68.175*mm, 68.075*mm, - 33.275*mm, 75.075*mm, 75.075*mm, - 78.075*mm, 75.075*mm, 273.075*mm - - - 8, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 21, 5, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 16, 5, 11, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 18, 5, 10, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 20, 5, 0, 28, 7, 7, 7, 4, 3, 6, - 19, 5, 9, 0, 28, 7, 7, 7, 27, 1, 27, 1, 3, 3, 6, - 17, 8, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 20, 5, 13, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, - 22, 5, 12, 0, 28, 7, 7, 7, 27, 1, 2, 3, 6, - 23, 5, 15, 0, 28, 7, 7, 7, 27, 1, 2, 6, - 21, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, - 20, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, 26, 8 + HEAirGap1, HEAirGap2, HEAirGap3, + HEAirGap4, HEAirGap5, HEAirGap6, + HEAirGap7, HEAirGap8, HEAirGap9, + HEAirGap10, HEAirGap11, HEAirGap12, + HEAirGap13, HEAirGap14, HEAirGap15, + HEAirGap16, HEAirGap17, HEAirGap18, + HECuKapton, HECuPCB, HEAirGap19, + HEAirGap20, HEAirGap21, + HEPCB, HEKapton, HECuWShield, + HECuShield, HEPCBShield, HEFeAbsorber, + HECuHeatShield, HESiliconSensitive, HEFeBox, + HEAirGap1, HEAirGap2, HEAirGap3, + HEAirGap4, HEAirGap5, HEAirGap6, + HEAirGap7, HEAirGap8, HEAirGap9, + HEAirGap10, HEAirGap11, HEAirGap12, + HEAirGap13, HEAirGap14, HEAirGap15, + HEAirGap16, HEAirGap17, HEAirGap18, + HECuKapton, HECuPCB, HEAirGap19, + HEAirGap20, HEAirGap21 + + [hgcal:thPCB], [hgcal:thKapton], [hgcal:thAbsHE], + [hgcal:thAbsCuHE], [hgcal:thAbsPCBHE], 40.0*mm, + 6.0*mm, [hgcal:thSilicon], 9.0*mm, + 10.7*mm, 12.8*mm, 13.8*mm, + 14.8*mm, 16.8*mm, 17.0*mm, + 18.0*mm, 3.0*mm, 4.0*mm, + 5.0*mm, 6.0*mm, 7.0*mm, + 8.0*mm, 9.0*mm, 10.0*mm, + 36.0*mm, 52.0*mm, 29.0*mm, + [hgcal:thCuKapton], [hgcal:thCuPCB], 8.8*mm, + 9.8*mm, [hgcal:thAbsCuHE], + [hgcal:thPCB], [hgcal:thKapton], [hgcal:thAbsHE], + [hgcal:thAbsCuHE], [hgcal:thAbsPCBHE], 40.0*mm, + 6.0*mm, [hgcal:thSilicon], 9.0*mm, + 10.7*mm, 12.8*mm, 13.8*mm, + 14.8*mm, 16.8*mm, 17.0*mm, + 18.0*mm, 3.0*mm, 4.0*mm, + 5.0*mm, 6.0*mm, 7.0*mm, + 8.0*mm, 9.0*mm, 10.0*mm, + 36.0*mm, 52.0*mm, 29.0*mm, + [hgcal:thCuKapton], [hgcal:thCuPCB], 8.8*mm, + 9.8*mm, [hgcal:thAbsCuHE] + + 28.075*mm, 67.075*mm, 67.075*mm, + 68.075*mm, 66.975*mm, 67.075*mm, + 169.075*mm, 74.075*mm, 74.075*mm, + 77.075*mm, 74.075*mm, 111.075*mm - - 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, + + + 0, 12, 25, 38, 51, 62, 77, 94,107,120,132,144 + + 11, 24, 37, 50, 61, 76, 93,106,119,131,143,157 + + 158,170,183,196,209,220,235,252,265,278,290,302 + + 169,182,195,208,219,234,251,264,277,289,301,315 + + 8, 29, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 21, 5, 29, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 16, 5, 11, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 18, 5, 10, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 20, 5, 30, 0, 28, 7, 7, 7, 4, 3, 6, + 19, 5, 9, 0, 28, 7, 7, 7, 27, 1, 27, 1, 3, 3, 6, + 17, 8, 24, 5, 25, 8, 29, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 20, 5, 13, 0, 28, 7, 7, 7, 27, 1, 3, 3, 6, + 22, 5, 12, 0, 28, 7, 7, 7, 27, 1, 2, 3, 6, + 23, 5, 15, 0, 28, 7, 7, 7, 27, 1, 2, 6, + 21, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, + 20, 5, 14, 0, 28, 7, 7, 7, 27, 1, 3, 6, 26, 8, + 40, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 53, 37, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 48, 37, 43, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 50, 37, 42, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 52, 37, 62, 63, 32, 60, 39, 39, 39, 36, 38, + 51, 37, 41, 63, 32, 60, 39, 39, 39, 59, 33, 59, 33, 35, 38, + 49, 40, 56, 37, 57, 40, 61, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 52, 37, 45, 63, 32, 60, 39, 39, 39, 59, 33, 35, 38, + 54, 37, 44, 63, 32, 60, 39, 39, 39, 59, 33, 34, 38, + 55, 37, 47, 63, 32, 60, 39, 39, 39, 59, 33, 38, + 53, 37, 46, 63, 32, 60, 39, 39, 39, 59, 33, 38, + 52, 37, 46, 63, 32, 60, 39, 39, 39, 59, 33, 38, 58, 40 + + 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, - 0, 0, 2, 8, 1, 1, 1, 6, 5, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 6, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 7, 3, 5, 5, 0, - 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 5, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, - 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, 0, 0 + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, 0, 0, + 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 6, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 7, 3, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 5, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 4, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, + 0, 0, 0, 0, 2, 8, 1, 1, 1, 7, 3, 0, 0, 0 + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -99,16 +192,8 @@ - - - 0.0, 0.0 - - 0, 0 - - [hgcal:zminHE], [hgcal:zmaxHE] - - [hgcal:rmaxHE], [hgcal:rmaxHE] - + + diff --git a/Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml b/Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml index a8e4bd4895f3b..34cdbe29069d4 100644 --- a/Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml +++ b/Geometry/HGCalCommonData/data/hgcal/v10/hgcal.xml @@ -13,30 +13,30 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + diff --git a/Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml b/Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml index 775baff44c9c2..478d92caef779 100644 --- a/Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml +++ b/Geometry/HGCalCommonData/data/hgcalHEmix/v10/hgcalHEmix.xml @@ -35,11 +35,11 @@ 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 - 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 + -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, + -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, + -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, + -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, + -1, 0, 0, 1, 0, -1, 0, 0, 1, 0 diff --git a/Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml b/Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml index a5e9dac5bca66..167c8c1c072eb 100644 --- a/Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml +++ b/Geometry/HGCalCommonData/data/hgcalHEsil/v10/hgcalHEsil.xml @@ -36,14 +36,14 @@ 1, 2, 3, 4, 5, 6, 8, 7, 8, 9, 8, 10, 11, 1, 2, 3, 4, 5, 6, 8, 7, 8, 9, 8, 10, 11 - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc index db962386bcd81..987862e421adb 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc @@ -4,6 +4,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" @@ -12,10 +13,10 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" //#define EDM_ML_DEBUG +using namespace geant_units; +using namespace geant_units::operators; DDHGCalEEAlgo::DDHGCalEEAlgo() { #ifdef EDM_ML_DEBUG @@ -103,6 +104,8 @@ void DDHGCalEEAlgo::initialize(const DDNumericArguments & nArgs, waferSize_ = nArgs["waferSize"]; waferSepar_ = nArgs["SensorSeparation"]; sectors_ = (int)(nArgs["Sectors"]); + alpha_ = piRadians/sectors_; + cosAlpha_ = cos(alpha_); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "zStart " << zMinBlock_ << " radius for wafer type separation uses " @@ -111,7 +114,8 @@ void DDHGCalEEAlgo::initialize(const DDNumericArguments & nArgs, << ":" << nCutRadPar_ << ":" << fracAreaMin_ << " wafer width " << waferSize_ << " separations " << waferSepar_ - << " sectors " << sectors_; + << " sectors " << sectors_ << ":" + << convertRadToDeg(alpha_) << ":" << cosAlpha_; for (unsigned int k=0; k zr = HGCalGeomTools::zradius(zz,zz+thick_[ii], + zFrontT_,rMaxFront_); zz += hthick; thickTot += thick_[ii]; @@ -203,23 +209,36 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDMaterial matter(matName); DDLogicalPart glog; if (layerSense_[ly] < 1) { - double alpha = CLHEP::pi/sectors_; - int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0) ? 2 : 2; + int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0 || + zr.first < 0) ? 2 : 3; std::vector pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); - double rmax = routF*cos(alpha) - tol; - pgonZ[0] =-hthick; pgonZ[1] = hthick; - pgonRin[0] = rinB; pgonRin[1] = rinB; - pgonRout[0] = rmax; pgonRout[1] = rmax; + if (layerSense_[ly] == 0 || absorbMode_ == 0) { + double rmax = routF*cosAlpha_ - tol; + pgonZ[0] =-hthick; pgonZ[1] = hthick; + pgonRin[0] = rinB; pgonRin[1] = rinB; + pgonRout[0] = rmax; pgonRout[1] = rmax; + } else { + for (int isec=0; isec rMaxFront_; //Corresponding rMax's std::string nameSpace_; //Namespace of this and ALL sub-parts std::unordered_set copies_; //List of copy #'s + double alpha_, cosAlpha_; }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc index 1b10c62b370e6..0919bda3e3159 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc @@ -4,6 +4,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" @@ -11,9 +12,9 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.h" #include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" +using namespace geant_units; +using namespace geant_units::operators; //#define EDM_ML_DEBUG DDHGCalHEAlgo::DDHGCalHEAlgo() { @@ -147,6 +148,8 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments & nArgs, waferSize_ = nArgs["waferSize"]; waferSepar_ = nArgs["SensorSeparation"]; sectors_ = (int)(nArgs["Sectors"]); + alpha_ = piRadians/sectors_; + cosAlpha_ = cos(alpha_); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: zStart " << zMinBlock_ << " radius for wafer type separation uses " @@ -155,7 +158,8 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments & nArgs, << ":" << nCutRadPar_ << ":" << fracAreaMin_ << " wafer width " << waferSize_ << " separations " << waferSepar_ - << " sectors " << sectors_; + << " sectors " << sectors_ << ":" + << convertRadToDeg(alpha_) << ":" << cosAlpha_; for (unsigned int k=0; k zr = HGCalGeomTools::zradius(zz,zz+thick_[ii], + zFrontT_,rMaxFront_); zz += hthick; thickTot += thick_[ii]; @@ -247,23 +253,38 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDMaterial matter(matName); DDLogicalPart glog; if (layerSense_[ly] < 1) { - double alpha = CLHEP::pi/sectors_; - int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0) ? 2 : 2; + int nsec = (layerSense_[ly] == 0 || absorbMode_ == 0 || + zr.first < 0) ? 2 : 3; std::vector pgonZ(nsec), pgonRin(nsec), pgonRout(nsec); - double rmax = routF*cos(alpha) - tol; - pgonZ[0] =-hthick; pgonZ[1] = hthick; - pgonRin[0] = rinB; pgonRin[1] = rinB; - pgonRout[0] = rmax; pgonRout[1] = rmax; + if (layerSense_[ly] == 0 || absorbMode_ == 0) { + double rmax = (std::min(routF, + HGCalGeomTools::radius(zz+hthick,zFrontT_,rMaxFront_,slopeT_))* + cosAlpha_) - tol; + pgonZ[0] =-hthick; pgonZ[1] = hthick; + pgonRin[0] = rinB; pgonRin[1] = rinB; + pgonRout[0] = rmax; pgonRout[1] = rmax; + } else { + for (int isec=0; isec rMaxFront_; //Corresponding rMax's std::string nameSpace_; //Namespace of this and ALL sub-parts std::unordered_set copies_; //List of copy #'s + double alpha_, cosAlpha_; }; #endif diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc new file mode 100644 index 0000000000000..aa828ddf87842 --- /dev/null +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.cc @@ -0,0 +1,370 @@ +#include +#include + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSolid.h" +#include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDutils.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h" + +//#define EDM_ML_DEBUG +using namespace geant_units::operators; + +DDHGCalTBModuleX::DDHGCalTBModuleX() : factor_(0.5*sqrt(2.0)), + tan30deg_(tan(30._deg)) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX info: Creating instance"; +#endif +} + +DDHGCalTBModuleX::~DDHGCalTBModuleX() {} + +void DDHGCalTBModuleX::initialize(const DDNumericArguments & nArgs, + const DDVectorArguments & vArgs, + const DDMapArguments & , + const DDStringArguments & sArgs, + const DDStringVectorArguments &vsArgs){ + + wafer_ = vsArgs["WaferName"]; + covers_ = vsArgs["CoverName"]; + genMat_ = sArgs["GeneralMaterial"]; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: Material " << genMat_ + << " with " << wafer_.size() << " wafers"; + unsigned int i(0); + for (auto wafer : wafer_) { + edm::LogVerbatim("HGCalGeom") << "Wafer[" << i << "] " << wafer; ++i;} + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << covers_.size() + << " covers"; + i = 0; + for (auto cover : covers_) { + edm::LogVerbatim("HGCalGeom") << "Cover[" << i << "] " << cover; ++i;} +#endif + materials_ = vsArgs["MaterialNames"]; + names_ = vsArgs["VolumeNames"]; + layerThick_ = vArgs["Thickness"]; + for (unsigned int k=0; k 1) { + layerFrontOut_ = dbl_to_int(vArgs["LayerFrontOut"]); + layerBackOut_ = dbl_to_int(vArgs["LayerBackOut"]); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << blockThick_.size() + << " blocks with in/out " << inOut_; + unsigned int lastF = ((inOut_ > 1) ? ((unsigned int)(layerFrontOut_[0])) : + blockThick_.size()); + for (unsigned int i=0; i 1) { + for (unsigned int i=lastF; i> Constructing DDHGCalTBModuleX..."; +#endif + copies_.clear(); + constructBlocks (parent(), cpv); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << copies_.size() + << " different wafer copy numbers"; +#endif + copies_.clear(); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "<<== End of DDHGCalTBModuleX construction"; +#endif +} + +void DDHGCalTBModuleX::constructBlocks(const DDLogicalPart& parent, + DDCompactView& cpv) { + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: Inside constructBlock"; +#endif + double zi(zMinBlock_); + for (unsigned int i=0; i 1) + constructLayers(i,layerFrontOut_[i],layerBackOut_[i],-0.5*blockThick_[i], + blockThick_[i],true,glog,cpv); + zi = zo; + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: All blocks are " + << "placed in " << zMinBlock_ << ":" << zi; +#endif +} + +void DDHGCalTBModuleX::constructLayers(int block, int firstLayer, + int lastLayer, double zFront, + double totalWidth, bool ignoreCenter, + const DDLogicalPart& module, + DDCompactView& cpv) { + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: \t\tInside Block " + << block << " Layers " << firstLayer << ":" + << lastLayer << " zFront " << zFront + << " thickness " << totalWidth + << " ignore Center " << ignoreCenter; +#endif + double zi(zFront), thickTot(0); + for (int ly=firstLayer; ly<=lastLayer; ++ly) { + int ii = layerType_[ly]; + int copy = copyNumber_[ii]; + double zz = zi + (0.5*layerThick_[ii]); + double zo = zi + layerThick_[ii]; + thickTot += layerThick_[ii]; + + std::string name = "HGCal"+names_[ii]+std::to_string(copy); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name << " Layer " + << ly << ":" << ii << " Z " << zi << ":" + << zo << " Thick " << layerThick_[ii] + << " Sense " << layerSense_[ly]; +#endif + DDName matName(DDSplit(materials_[ii]).first, + DDSplit(materials_[ii]).second); + DDMaterial matter(matName); + DDLogicalPart glog; + if (layerSense_[ly] == 0) { + DDSolid solid = DDSolidFactory::box(DDName(name, idNameSpace_), + absorbW_, absorbH_, + 0.5*layerThick_[ii]); + glog = DDLogicalPart(solid.ddname(), matter, solid); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " + << solid.name() << " box of dimension " + << absorbW_ << ":" << absorbH_ + << ":" << 0.5*layerThick_[ii]; +#endif + DDTranslation r1(0,0,zz); + DDRotation rot; + cpv.position(glog, module, copy, r1, rot); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << glog.name() + << " number " << copy + << " positioned in " << module.name() + << " at " << r1 << " with " << rot; +#endif + } else if (layerSense_[ly] > 0) { + positionSensitive(zz, copy, layerSense_[ly], rMax_, maxModule_[ly], + ignoreCenter, name, matter, module, cpv); + } + ++copyNumber_[ii]; + zi = zo; + } // End of loop over layers in a block + + if (fabs(thickTot-totalWidth) < tolerance_) { + } else if (thickTot > totalWidth) { + edm::LogError("HGCalGeom") << "Thickness of the partition " + << totalWidth << " is smaller than " << thickTot + << ": total thickness of all its components in " + << module.name() << " Layers " << firstLayer + << ":" << lastLayer << ":" << ignoreCenter + << "**** ERROR ****"; + } else if (thickTot < totalWidth) { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " + << totalWidth << " does not match with " + << thickTot << " of the components in " + << module.name() << " Layers " << firstLayer + << ":" << lastLayer << ":" << ignoreCenter; + } +} + +void DDHGCalTBModuleX::positionSensitive(double zpos, int copyIn, int type, + double rout, int ncrMax, + bool ignoreCenter, + const std::string& nameIn, + const DDMaterial& matter, + const DDLogicalPart& glog, + DDCompactView& cpv) { + double ww = (waferW_+waferGap_); + double dx = 0.5*ww; + double dy = 3.0*dx*tan30deg_; + double rr = 2.0*dx*tan30deg_; + int ncol = (int)(2.0*rout/ww) + 1; + int nrow = (int)(rout/(ww*tan30deg_)) + 1; +#ifdef EDM_ML_DEBUG + int incm(0), inrm(0); + edm::LogVerbatim("HGCalGeom") << glog.ddname() << " Copy " << copyIn + << " Type " << type << " rout " << rout + << " Row " << nrow << " column " << ncol + << " ncrMax " << ncrMax << " Z " << zpos + << " Center " << ignoreCenter << " name " + << nameIn << " matter " << matter.name(); + int kount(0); +#endif + if (ncrMax >= 0) { + nrow = std::min(nrow,ncrMax); + ncol = std::min(ncol,ncrMax); + } + for (int nr=-nrow; nr <= nrow; ++nr) { + int inr = std::abs(nr); + for (int nc=-ncol; nc <= ncol; ++nc) { + int inc = std::abs(nc); + if ((inr%2 == inc%2) && (!ignoreCenter || nc != 0 || nr != 0)) { + double xpos = nc*dx; + double ypos = nr*dy; + double xc[6], yc[6]; + xc[0] = xpos+dx; yc[0] = ypos-0.5*rr; + xc[1] = xpos+dx; yc[1] = ypos+0.5*rr; + xc[2] = xpos; yc[2] = ypos+rr; + xc[3] = xpos-dx; yc[3] = ypos+0.5*rr; + xc[4] = xpos+dx; yc[4] = ypos-0.5*rr; + xc[5] = xpos; yc[5] = ypos-rr; + bool cornerAll(true); + for (int k=0; k<6; ++k) { + double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]); + if (rpos > rout) cornerAll = false; + } + if (cornerAll) { + double rpos = std::sqrt(xpos*xpos+ypos*ypos); + DDTranslation tran(xpos, ypos, zpos); + DDRotation rotation; + int copy = inr*100 + inc; + if (nc < 0) copy += 10000; + if (nr < 0) copy += 100000; + DDName name, nameX; + if (type == 1) { + nameX = DDName(DDSplit(covers_[0]).first, + DDSplit(covers_[0]).second); + std::string name0 = nameIn + "M" + std::to_string(copy); + DDLogicalPart glog1 = DDLogicalPart(DDName(name0, idNameSpace_), + matter, nameX); + cpv.position(glog1.ddname(),glog.ddname(),copyIn,tran,rotation); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " + << glog1.ddname() << " number " + << copyIn << " positioned in " + << glog.ddname() << " at " << tran + << " with " << rotation; +#endif + name = (rpos < rMaxFine_) ? + DDName(DDSplit(wafer_[0]).first, DDSplit(wafer_[0]).second) : + DDName(DDSplit(wafer_[1]).first, DDSplit(wafer_[1]).second); + DDTranslation tran1; + cpv.position(name, glog1.ddname(), copy, tran1, rotation); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name + << " number " << copy + << " positioned in " + << glog1.ddname() << " at " << tran1 + << " with " << rotation; +#endif + if (copies_.count(copy) == 0 && type == 1) copies_.insert(copy); + } else { + name = DDName(DDSplit(covers_[type-1]).first, + DDSplit(covers_[type-1]).second); + copy += copyIn*1000000; + cpv.position(name, glog.ddname(), copy, tran, rotation); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name + << " number " << copy + << " positioned in " + << glog.ddname() << " at " << tran + << " with " << rotation; +#endif + } +#ifdef EDM_ML_DEBUG + if (inc > incm) incm = inc; + if (inr > inrm) inrm = inr; + kount++; +#endif + } + } + } + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: # of columns " << incm + << " # of rows " << inrm << " and " << kount + << " wafers for " << glog.ddname(); +#endif +} diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h new file mode 100644 index 0000000000000..c6c28c9292e92 --- /dev/null +++ b/Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h @@ -0,0 +1,71 @@ +#ifndef HGCalCommonData_DDHGCalTBModuleX_h +#define HGCalCommonData_DDHGCalTBModuleX_h + +#include +#include +#include "DetectorDescription/Core/interface/DDTypes.h" +#include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDMaterial.h" +#include + +class DDHGCalTBModuleX : public DDAlgorithm { + +public: + //Constructor and Destructor + DDHGCalTBModuleX(); // + ~DDHGCalTBModuleX() override; + + void initialize(const DDNumericArguments & nArgs, + const DDVectorArguments & vArgs, + const DDMapArguments & mArgs, + const DDStringArguments & sArgs, + const DDStringVectorArguments & vsArgs) override; + void execute(DDCompactView& cpv) override; + +protected: + + void constructBlocks (const DDLogicalPart&, DDCompactView& cpv); + void constructLayers (int block, int layerFront, int layerBack, + double zFront, double thick, bool ignore, + const DDLogicalPart&, DDCompactView&); + void positionSensitive(double zpos, int copyIn, int type, + double rmax, int ncrMax, bool ignoreCenter, + const std::string&, const DDMaterial&, + const DDLogicalPart&, DDCompactView& cpv); + +private: + + static constexpr double tolerance_ = 0.00001; + const double factor_, tan30deg_; + + std::vector wafer_; //Wafers + std::vector covers_; //Insensitive layers of hexagonal size + std::string genMat_; //General material used for blocks + std::vector materials_; //Material names in each layer + std::vector names_; //Names of each layer + std::vector layerThick_; //Thickness of the material + std::vector copyNumber_; //Copy numbers (initiated to 1) + std::vector blockThick_; //Thickness of each section + int inOut_; //Number of inner+outer parts + std::vector layerFrontIn_; //First layer index (inner) in block + std::vector layerBackIn_; //Last layer index (inner) in block + std::vector layerFrontOut_;//First layer index (outner) in block + std::vector layerBackOut_; //Last layer index (outner) in block + std::vector layerType_; //Type of the layer + std::vector layerSense_; //Content of a layer + std::vector maxModule_; //Maximum # of row/column + double zMinBlock_; //Starting z-value of the block + double rMaxFine_; //Maximum r-value for fine wafer + double waferW_; //Width of the wafer + double waferGap_; //Gap between 2 wafers + double absorbW_; //Width of the absorber + double absorbH_; //Height of the absorber + double rMax_; //Maximum radial extent + double rMaxB_; //Maximum radial extent of a block + std::string idName_; //Name of the "parent" volume. + std::string idNameSpace_; //Namespace of this and ALL sub-parts + std::unordered_set copies_; //List of copy #'s +}; + +#endif diff --git a/Geometry/HGCalCommonData/plugins/module.cc b/Geometry/HGCalCommonData/plugins/module.cc index a700bd81835b8..56883f4d45cf4 100644 --- a/Geometry/HGCalCommonData/plugins/module.cc +++ b/Geometry/HGCalCommonData/plugins/module.cc @@ -7,6 +7,7 @@ #include "Geometry/HGCalCommonData/plugins/DDHGCalModule.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalModuleAlgo.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalTBModule.h" +#include "Geometry/HGCalCommonData/plugins/DDHGCalTBModuleX.h" #include "Geometry/HGCalCommonData/plugins/DDHGCalNoTaperEndcap.h" #include "Geometry/HGCalCommonData/plugins/DDAHcalModuleAlgo.h" #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h" @@ -20,5 +21,6 @@ DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalWafer8, "hgcal:DDHGCalWafer8"); DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalModule, "hgcal:DDHGCalModule"); DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalModuleAlgo, "hgcal:DDHGCalModuleAlgo"); DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalTBModule, "hgcal:DDHGCalTBModule"); +DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalTBModuleX, "hgcal:DDHGCalTBModuleX"); DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDHGCalNoTaperEndcap, "hgcal:DDHGCalNoTaperEndcap"); DEFINE_EDM_PLUGIN (DDAlgorithmFactory, DDAHcalModuleAlgo, "hgcal:DDAHcalModuleAlgo"); diff --git a/Geometry/HGCalCommonData/python/testHGCV10XML_cfi.py b/Geometry/HGCalCommonData/python/testHGCV10XML_cfi.py index d9aa3072863f5..29b9c32bcb826 100644 --- a/Geometry/HGCalCommonData/python/testHGCV10XML_cfi.py +++ b/Geometry/HGCalCommonData/python/testHGCV10XML_cfi.py @@ -36,6 +36,8 @@ 'Geometry/HGCalCommonData/data/hgcalwafer/v9/hgcalwafer.xml', 'Geometry/HGCalCommonData/data/hgcalcell/v9/hgcalcell.xml', 'Geometry/HGCalCommonData/data/hgcalCons/v10/hgcalCons.xml', + 'Geometry/HGCalSimData/data/hgcsensv9.xml', + 'Geometry/HGCalSimData/data/hgcProdCutsv9.xml', )+ cms.vstring( 'Geometry/CMSCommonData/data/FieldParameters.xml', diff --git a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc index 84ae4128e76af..01db327a043fe 100644 --- a/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc +++ b/Geometry/HGCalCommonData/src/HGCalGeomParameters.cc @@ -50,8 +50,8 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, DDFilteredView fv = _fv; bool dodet(true); std::map layers; - std::vector trforms; - std::vector trformUse; + std::vector trforms; + std::vector trformUse; while (dodet) { const DDSolid & sol = fv.logicalPart().solid(); @@ -70,10 +70,20 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, php.layer_.end()) php.layer_.emplace_back(lay); auto itr = layers.find(lay); if (itr == layers.end()) { - const DDTubs & tube = static_cast(sol); - double rin = HGCalParameters::k_ScaleFromDDD*tube.rIn(); - double rout= HGCalParameters::k_ScaleFromDDD*tube.rOut(); - double zp = HGCalParameters::k_ScaleFromDDD*fv.translation().Z(); + double rin(0), rout(0); + if ((sol.shape() == DDSolidShape::ddpolyhedra_rz) || + (sol.shape() == DDSolidShape::ddpolyhedra_rrz)) { + const DDPolyhedra& polyhedra = static_cast(sol); + const std::vector& rmin = polyhedra.rMinVec(); + const std::vector& rmax = polyhedra.rMaxVec(); + rin = 0.5*HGCalParameters::k_ScaleFromDDD*(rmin[0]+rmin[1]); + rout = 0.5*HGCalParameters::k_ScaleFromDDD*(rmax[0]+rmax[1]); + } else if (sol.shape() == DDSolidShape::ddtubs) { + const DDTubs & tube = static_cast(sol); + rin = HGCalParameters::k_ScaleFromDDD*tube.rIn(); + rout = HGCalParameters::k_ScaleFromDDD*tube.rOut(); + } + double zp = HGCalParameters::k_ScaleFromDDD*fv.translation().Z(); HGCalGeomParameters::layerParameters laypar(rin,rout,zp); layers[lay] = laypar; } @@ -133,13 +143,18 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, edm::LogError("HGCalGeom") << "Funny wafer # " << wafer << " in " << nsiz << " components"; throw cms::Exception("DDException") << "Funny wafer # " << wafer; + } else if (layer > (int)(layers.size())) { + edm::LogWarning("HGCalGeom") << "Funny wafer # " << wafer + << " Layer " << layer << ":" + << layers.size() << " among " + << nsiz << " components"; } else { auto itr = copies.find(wafer); auto cpy = copiesInLayers[layer].find(wafer); if (itr != copies.end() && cpy == copiesInLayers[layer].end()) { copiesInLayers[layer][wafer] = itr->second; - } - if (itr == copies.end()) { + } + if (itr == copies.end()) { copies[wafer] = wafer2copy.size(); copiesInLayers[layer][wafer] = wafer2copy.size(); double xx = HGCalParameters::k_ScaleFromDDD*fv1.translation().X(); @@ -182,7 +197,7 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, dodet = fv1.next(); } } - + // Finally the cells std::map wafertype; std::map cellsf, cellsc; @@ -250,7 +265,7 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv, dodet = fv2.next(); } } - + if (((cellsf.size()+cellsc.size())==0) || (wafers.empty()) || (layers.empty())) { edm::LogError("HGCalGeom") << "HGCalGeomParameters : number of cells " diff --git a/Geometry/HGCalCommonData/src/HGCalWaferType.cc b/Geometry/HGCalCommonData/src/HGCalWaferType.cc index 47e81c7ae3c10..20ab5be41b2df 100644 --- a/Geometry/HGCalCommonData/src/HGCalWaferType.cc +++ b/Geometry/HGCalCommonData/src/HGCalWaferType.cc @@ -1,7 +1,6 @@ #include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" #include "Geometry/HGCalCommonData/interface/HGCalParameters.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include //#define EDM_ML_DEBUG diff --git a/Geometry/HGCalGeometry/interface/HGCalGeometry.h b/Geometry/HGCalGeometry/interface/HGCalGeometry.h index de28dbee9bce8..32a084c916c9e 100644 --- a/Geometry/HGCalGeometry/interface/HGCalGeometry.h +++ b/Geometry/HGCalGeometry/interface/HGCalGeometry.h @@ -77,7 +77,10 @@ class HGCalGeometry final: public CaloSubdetectorGeometry { CaloSubdetectorGeometry::IVec& dinsVector ) const override; GlobalPoint getPosition( const DetId& id ) const; - + + /// Returns area of a cell + double getArea(const DetId& detid) const; + /// Returns the corner points of this cell's volume. CornersVec getCorners( const DetId& id ) const; CornersVec get8Corners( const DetId& id ) const; diff --git a/Geometry/HGCalGeometry/src/HGCalGeometry.cc b/Geometry/HGCalGeometry/src/HGCalGeometry.cc index 6109ac5bb93f3..743a3fcc7a7fd 100644 --- a/Geometry/HGCalGeometry/src/HGCalGeometry.cc +++ b/Geometry/HGCalGeometry/src/HGCalGeometry.cc @@ -272,6 +272,22 @@ GlobalPoint HGCalGeometry::getPosition(const DetId& detid) const { return glob; } +double HGCalGeometry::getArea(const DetId& detid) const { + + HGCalGeometry::CornersVec corners = getNewCorners(detid); + double area(0); + if (corners.size() > 1) { + int n = corners.size()-1; + int j = n-1; + for (int i=0; igetArea(id) << std::endl; ++kount; } } diff --git a/Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py b/Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py index b5c804f21cb6c..0f7d539667a06 100644 --- a/Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py +++ b/Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py @@ -7,7 +7,7 @@ #process.load("Geometry.HGCalCommonData.hgcalV6NumberingInitialization_cfi") #process.load("Geometry.HGCalCommonData.hgcalV6ParametersInitialization_cfi") #process.load("Geometry.CaloEventSetup.HGCalV6Topology_cfi") -process.load("Geometry.HGCalCommonData.testHGCXML_cfi") +process.load("Geometry.HGCalCommonData.testHGCV10XML_cfi") process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi") process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi") process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi") diff --git a/Geometry/HcalAlgo/plugins/DDHCalFibreBundle.cc b/Geometry/HcalAlgo/plugins/DDHCalFibreBundle.cc index ff2c02c5f66fe..bcead5d1184af 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalFibreBundle.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalFibreBundle.cc @@ -7,6 +7,7 @@ #include #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDSolid.h" @@ -14,10 +15,14 @@ #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "Geometry/HcalAlgo/plugins/DDHCalFibreBundle.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHCalFibreBundle::DDHCalFibreBundle() { - LogDebug("HCalGeom") <<"DDHCalFibreBundle info: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating an instance"; +#endif } DDHCalFibreBundle::~DDHCalFibreBundle() {} @@ -40,25 +45,30 @@ void DDHCalFibreBundle::initialize(const DDNumericArguments & nArgs, idNameSpace = DDCurrentNamespace::ns(); childPrefix = sArgs["Child"]; - DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalFibreBundle debug: Parent " << parentName - << " with " << bundle.size() << " children with prefix " - << childPrefix << ", material " << material << " with " - << numberPhi << " bundles along phi; width of mother " - << deltaZ << " along Z, " << deltaPhi/CLHEP::deg - << " along phi and with " << rStart.size() - << " different bundle types"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Parent " + << parent().name() << " with " << bundle.size() + << " children with prefix " << childPrefix + << ", material " << material << " with " + << numberPhi << " bundles along phi; width of" + << " mother " << deltaZ << " along Z, " + << convertRadToDeg(deltaPhi) + << " along phi and with " << rStart.size() + << " different bundle types"; for (unsigned int i=0; i rotation; for (int i=0; i=0 && ib<(int)(logs.size())) { cpv.position(logs[ib], mother, copy, tran, rotation[ir]); - LogDebug("HCalGeom") << "DDHCalFibreBundle test: " << logs[ib].name() - << " number " << copy << " positioned in " - << mother << " at " << tran << " with " - << rotation[ir]; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: " << logs[ib].name() + << " number " << copy << " positioned in " + << mother << " at " << tran << " with " + << rotation[ir]; +#endif } } } diff --git a/Geometry/HcalAlgo/plugins/DDHCalForwardAlgo.cc b/Geometry/HcalAlgo/plugins/DDHCalForwardAlgo.cc index 44d5c29c2a6a2..166218c8ba14b 100644 --- a/Geometry/HcalAlgo/plugins/DDHCalForwardAlgo.cc +++ b/Geometry/HcalAlgo/plugins/DDHCalForwardAlgo.cc @@ -6,7 +6,6 @@ #include #include -namespace std{} using namespace std; #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DetectorDescription/Core/interface/DDutils.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" @@ -16,13 +15,16 @@ namespace std{} using namespace std; #include "DetectorDescription/Core/interface/DDSplit.h" #include "Geometry/HcalAlgo/plugins/DDHCalForwardAlgo.h" +//#define EDM_ML_DEBUG + DDHCalForwardAlgo::DDHCalForwardAlgo(): number(0),size(0),type(0) { - LogDebug("HCalGeom") << "DDHCalForwardAlgo info: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Creating an instance"; +#endif } DDHCalForwardAlgo::~DDHCalForwardAlgo() {} - void DDHCalForwardAlgo::initialize(const DDNumericArguments & nArgs, const DDVectorArguments & vArgs, const DDMapArguments & , @@ -40,27 +42,32 @@ void DDHCalForwardAlgo::initialize(const DDNumericArguments & nArgs, size = dbl_to_int(vArgs["Size"]); type = dbl_to_int(vArgs["Type"]); - LogDebug("HCalGeom") << "DDHCalForwardAlgo debug: Cell material " << cellMat - << "\tCell Size " << cellDx << ", " << cellDy << ", " - << cellDz << "\tStarting Y " << startY << "\tChildren " - << childName[0] << ", " << childName[1] << "\n" - << " Cell positioning done for " - << number.size() << " times"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Cell material " + << cellMat << "\tCell Size " << cellDx << ", " + << cellDy << ", " << cellDz << "\tStarting Y " + << startY << "\tChildren " << childName[0] + << ", " << childName[1] << "\n " + << " Cell positioning done for " + << number.size() << " times"; for (unsigned int i = 0; i < number.size(); i++) - LogDebug("HCalGeom") << "\t" << i << " Number of children " << size[i] - << " occurence " << number[i] << " first child index " - << type[i]; - + edm::LogVerbatim("HCalGeom") << "\t" << i << " Number of children " + << size[i] << " occurence " << number[i] + << " first child index " << type[i]; +#endif idNameSpace = DDCurrentNamespace::ns(); - DDName parentName = parent().name(); - LogDebug("HCalGeom") << "DDHCalForwardAlgo debug: Parent " << parentName - << " NameSpace " << idNameSpace; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo debug: Parent " + << parent().name() << " NameSpace " + << idNameSpace; +#endif } void DDHCalForwardAlgo::execute(DDCompactView& cpv) { - LogDebug("HCalGeom") << "==>> Constructing DDHCalForwardAlgo..."; - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalForwardAlgo..."; +#endif DDName parentName = parent().name(); double ypos = startY; int box = 0; @@ -70,14 +77,15 @@ void DDHCalForwardAlgo::execute(DDCompactView& cpv) { int indx = type[i]; for (int j=0; j #include -namespace std{} using namespace std; - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Math/interface/GeantUnits.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDSolid.h" #include "DetectorDescription/Core/interface/DDMaterial.h" #include "DetectorDescription/Core/interface/DDCurrentNamespace.h" #include "DetectorDescription/Core/interface/DDSplit.h" #include "Geometry/HcalAlgo/plugins/DDHCalTBCableAlgo.h" -#include "CLHEP/Units/GlobalPhysicalConstants.h" -#include "CLHEP/Units/GlobalSystemOfUnits.h" + +//#define EDM_ML_DEBUG +using namespace geant_units::operators; DDHCalTBCableAlgo::DDHCalTBCableAlgo(): theta(0),rmax(0),zoff(0) { - LogDebug("HCalGeom") << "DDHCalTBCableAlgo info: Creating an instance"; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "DDHCalTBCableAlgo: Creating an instance"; +#endif } DDHCalTBCableAlgo::~DDHCalTBCableAlgo() {} @@ -48,34 +50,40 @@ void DDHCalTBCableAlgo::initialize(const DDNumericArguments & nArgs, length2 = nArgs["Length2"]; gap2 = nArgs["Gap2"]; - LogDebug("HCalGeom") << "DDHCalTBCableAlgo debug: General material " - << genMat << "\tSectors " << nsectors << ", " - << nsectortot << "\tHalves " << nhalf << "\tRin " <> Constructing DDHCalTBCableAlgo..."; - unsigned int i=0; - - double alpha = CLHEP::pi/nsectors; - double dphi = nsectortot*CLHEP::twopi/nsectors; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HCalGeom") << "==>> Constructing DDHCalTBCableAlgo..."; +#endif + double alpha = 1._pi/nsectors; + double dphi = nsectortot*2._pi/nsectors; + double zstep0 = zoff[1]+rmax[1]*tan(theta[1])+(rin-rmax[1])*tan(theta[2]); double zstep1 = zstep0+thick/cos(theta[2]); double zstep2 = zoff[3]; @@ -83,39 +91,29 @@ void DDHCalTBCableAlgo::execute(DDCompactView& cpv) { double rstep0 = rin + (zstep2-zstep1)/tan(theta[2]); double rstep1 = rin + (zstep1-zstep0)/tan(theta[2]); - vector pgonZ; - pgonZ.emplace_back(zstep0); - pgonZ.emplace_back(zstep1); - pgonZ.emplace_back(zstep2); - pgonZ.emplace_back(zstep2+thick/cos(theta[2])); - - vector pgonRmin; - pgonRmin.emplace_back(rin); - pgonRmin.emplace_back(rin); - pgonRmin.emplace_back(rstep0); - pgonRmin.emplace_back(rmax[2]); - - vector pgonRmax; - pgonRmax.emplace_back(rin); - pgonRmax.emplace_back(rstep1); - pgonRmax.emplace_back(rmax[2]); - pgonRmax.emplace_back(rmax[2]); + std::vector pgonZ = {zstep0, zstep1, zstep2, + zstep2+thick/cos(theta[2])}; + + std::vector pgonRmin = {rin, rin, rstep0, rmax[2]}; + std::vector pgonRmax = {rin, rstep1, rmax[2], rmax[2]}; - string name("Null"); + std::string name("Null"); DDSolid solid; solid = DDSolidFactory::polyhedra(DDName(idName, idNameSpace), nsectortot, -alpha, dphi, pgonZ, pgonRmin, pgonRmax); - LogDebug("HCalGeom") << "DDHCalTBCableAlgo test: " - << DDName(idName,idNameSpace) << " Polyhedra made of " - << genMat << " with " << nsectortot << " sectors from " - << -alpha/CLHEP::deg << " to " - << (-alpha+dphi)/CLHEP::deg << " and with " - << pgonZ.size() << " sections"; - for (i = 0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + + + + + + + + +0,0,2.85 + + + + + + + + + + + + + +0,0,-2.85 + + + + + + diff --git a/Geometry/MTDCommonData/data/etl/v1/etl.xml b/Geometry/MTDCommonData/data/etl/v1/etl.xml new file mode 100644 index 0000000000000..bd923adda0417 --- /dev/null +++ b/Geometry/MTDCommonData/data/etl/v1/etl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/MTDCommonData/data/etl/v2/etl.xml b/Geometry/MTDCommonData/data/etl/v2/etl.xml new file mode 100644 index 0000000000000..9a3492dbb8b03 --- /dev/null +++ b/Geometry/MTDCommonData/data/etl/v2/etl.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/RPCGeometryBuilder/data/2023/v1/RPCSpecs.xml b/Geometry/RPCGeometryBuilder/data/2023/v1/RPCSpecs.xml new file mode 100644 index 0000000000000..9e0fd5d7e0046 --- /dev/null +++ b/Geometry/RPCGeometryBuilder/data/2023/v1/RPCSpecs.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/VeryForwardGeometry/interface/CTPPSPixelSimTopology.h b/Geometry/VeryForwardGeometry/interface/CTPPSPixelSimTopology.h index 10864fa53e94b..960345c364760 100644 --- a/Geometry/VeryForwardGeometry/interface/CTPPSPixelSimTopology.h +++ b/Geometry/VeryForwardGeometry/interface/CTPPSPixelSimTopology.h @@ -60,66 +60,66 @@ class CTPPSPixelSimTopology : public CTPPSPixelTopology // rows (x segmentation) if ( arow == 0 ) { - lower_x = 0; - higher_x = 0.3; + lower_x = dead_edge_width_ - phys_active_edge_dist_; // 50 um + higher_x = dead_edge_width_ + pitch_simX_; // 300 um } else if ( arow <= 78 ) { - lower_x = 0.3 + ( arow-1 )*pitch_simX_; - higher_x = 0.3 + arow *pitch_simX_; + lower_x = dead_edge_width_ + arow*pitch_simX_; + higher_x = dead_edge_width_ + ( arow+1 )*pitch_simX_; } else if ( arow == 79 ) { - lower_x = 0.3 + ( arow-1 )*pitch_simX_; - higher_x = 0.3 + ( arow+1 )*pitch_simX_; + lower_x = dead_edge_width_ + arow*pitch_simX_; + higher_x = dead_edge_width_ + ( arow+2 )*pitch_simX_; } else if ( arow == 80 ) { - lower_x = 0.3 + arow *pitch_simX_; - higher_x = 0.3 + ( arow+2 )*pitch_simX_; + lower_x = dead_edge_width_ + ( arow+1 )*pitch_simX_; + higher_x = dead_edge_width_ + ( arow+3 )*pitch_simX_; } else if ( arow <= 158 ) { - lower_x = 0.3 + ( arow+1 )*pitch_simX_; - higher_x = 0.3 + ( arow+2 )*pitch_simX_; + lower_x = dead_edge_width_ + ( arow+2 )*pitch_simX_; + higher_x = dead_edge_width_ + ( arow+3 )*pitch_simX_; } else if ( arow == 159) { - lower_x = 0.3 + ( arow+1 )*pitch_simX_; - higher_x = 0.3 + ( arow+4 )*pitch_simX_; + lower_x = dead_edge_width_ + ( arow+2 )*pitch_simX_; + higher_x = dead_edge_width_ + ( arow+3 )*pitch_simX_ + phys_active_edge_dist_ ; } // columns (y segmentation) if( acol == 0 ) { - lower_y = 0; - higher_y = 0.35; + lower_y = dead_edge_width_ - phys_active_edge_dist_; // 50 um + higher_y = dead_edge_width_ + pitch_simY_; // 350 um } else if ( acol <= 50 ) { - lower_y = 0.35 + ( acol-1 )*pitch_simY_; - higher_y = 0.35 + acol *pitch_simY_; + lower_y = dead_edge_width_ + acol*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+1 )*pitch_simY_; } else if ( acol == 51 ) { - lower_y = 0.35 + ( acol-1 )*pitch_simY_; - higher_y = 0.35 + ( acol+1 )*pitch_simY_; + lower_y = dead_edge_width_ + acol*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+2 )*pitch_simY_; } else if ( acol == 52 ) { - lower_y = 0.35 + acol *pitch_simY_; - higher_y = 0.35 + ( acol+2 )*pitch_simY_; + lower_y = dead_edge_width_ + ( acol+1 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+3 )*pitch_simY_; } else if ( acol <= 102 ) { - lower_y = 0.35 + ( acol+1 )*pitch_simY_; - higher_y = 0.35 + ( acol+2 )*pitch_simY_; + lower_y = dead_edge_width_ + ( acol+2 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+3 )*pitch_simY_; } else if ( acol == 103 ) { - lower_y = 0.35 + ( acol+1 )*pitch_simY_; - higher_y = 0.35 + ( acol+3 )*pitch_simY_; + lower_y = dead_edge_width_ + ( acol+2 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+4 )*pitch_simY_; } else if ( acol == 104) { - lower_y = 0.35 + ( acol+2 )*pitch_simY_; - higher_y = 0.35 + ( acol+4 )*pitch_simY_; + lower_y = dead_edge_width_ + ( acol+3 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+5 )*pitch_simY_; } else if ( acol <= 154 ) { - lower_y = 0.35 + ( acol+3 )*pitch_simY_; - higher_y = 0.35 + ( acol+4 )*pitch_simY_; + lower_y = dead_edge_width_ + ( acol+4 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+5 )*pitch_simY_; } else if ( acol == 155 ) { - lower_y = 0.35 + ( acol+3 )*pitch_simY_; - higher_y = 0.35 + ( acol+4 )*pitch_simY_ + 0.2; + lower_y = dead_edge_width_ + ( acol+4 )*pitch_simY_; + higher_y = dead_edge_width_ + ( acol+5 )*pitch_simY_ + phys_active_edge_dist_ ; } lower_x = lower_x - simX_width_/2.; diff --git a/Geometry/VeryForwardGeometry/interface/CTPPSPixelTopology.h b/Geometry/VeryForwardGeometry/interface/CTPPSPixelTopology.h index 60f9f11ac4c1d..14aacad0bb0f3 100644 --- a/Geometry/VeryForwardGeometry/interface/CTPPSPixelTopology.h +++ b/Geometry/VeryForwardGeometry/interface/CTPPSPixelTopology.h @@ -38,6 +38,26 @@ class CTPPSPixelTopology inline double activeEdgeSigma() const { return active_edge_sigma_; } inline double physActiveEdgeDist() const { return phys_active_edge_dist_; } + + static bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2 = true) + { +// check hit fiducial boundaries + double xModuleSize = 2*((no_of_pixels_simX_/2. + 1)*pitch_simX_ + dead_edge_width_); + if(xLocalCoordinate < -xModuleSize/2. || xLocalCoordinate > xModuleSize/2.) + return false; + + double yModuleSize = (no_of_pixels_simY_ + 4.)*pitch_simY_ + 2.*dead_edge_width_; + double y2x2top = no_of_pixels_simY_/6.*pitch_simY_ + dead_edge_width_; + if(is3x2 && (yLocalCoordinate < -yModuleSize/2. || yLocalCoordinate > yModuleSize/2.)) + return false; + + if(!is3x2 && (yLocalCoordinate < -yModuleSize/2. || yLocalCoordinate > y2x2top)) + return false; + + return true; + + } + CTPPSPixelIndices indices_; }; diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 4f429b96d56d9..4eaa9872360ca 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -48,10 +48,20 @@ def customiseFor2017DtUnpacking(process): return process +# type of parameter changed +def customiseFor24501(process): + for producer in producers_by_type(process, "PFRecoTauDiscriminationByIsolation"): + if hasattr(producer, "deltaBetaPUTrackPtCutOverride") and not isinstance(producer.deltaBetaPUTrackPtCutOverride, cms.bool): + producer.deltaBetaPUTrackPtCutOverride_val = producer.deltaBetaPUTrackPtCutOverride + producer.deltaBetaPUTrackPtCutOverride = cms.bool(True) + return process + + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): # add call to action function in proper order: newest last! # process = customiseFor12718(process) + process = customiseFor24501(process) return process diff --git a/IOMC/EventVertexGenerators/BuildFile.xml b/IOMC/EventVertexGenerators/BuildFile.xml index f82b4ec179900..86b4a6e9eef6e 100644 --- a/IOMC/EventVertexGenerators/BuildFile.xml +++ b/IOMC/EventVertexGenerators/BuildFile.xml @@ -10,4 +10,5 @@ + diff --git a/IOMC/EventVertexGenerators/interface/PassThroughEvtVtxGenerator.h b/IOMC/EventVertexGenerators/interface/PassThroughEvtVtxGenerator.h new file mode 100644 index 0000000000000..7dbfb613b86ed --- /dev/null +++ b/IOMC/EventVertexGenerators/interface/PassThroughEvtVtxGenerator.h @@ -0,0 +1,44 @@ +#ifndef IOMC_EventVertexGenerators_PassThroughEvtVtxGenerator_H +#define IOMC_EventVertexGenerators_PassThroughEvtVtxGenerator_H +/* +*/ + +#include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Utilities/interface/EDGetToken.h" + +#include "TMatrixD.h" + +namespace HepMC { + class FourVector ; +} + +namespace CLHEP { + class HepRandomEngine; +} + +namespace edm { + class HepMCProduct; +} + +class PassThroughEvtVtxGenerator : public BaseEvtVtxGenerator +{ + public: + + // ctor & dtor + explicit PassThroughEvtVtxGenerator( const edm::ParameterSet& ); + ~PassThroughEvtVtxGenerator() override; + + void produce( edm::Event&, const edm::EventSetup&) override; + + HepMC::FourVector newVertex(CLHEP::HepRandomEngine*) const override; + + TMatrixD const* GetInvLorentzBoost() const override { return nullptr;}; + + private : + + edm::EDGetTokenT sourceToken; + +}; + +#endif diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py index f9089095c7e59..d2b7b74b9e3d2 100644 --- a/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py +++ b/IOMC/EventVertexGenerators/python/VtxSmearedParameters_cfi.py @@ -33,6 +33,50 @@ SigmaZ = cms.double(4.0), TimeOffset = cms.double(0.0) ) +# Gaussian smearing +# Flat optics for Run3 - Low SigmaZ +# SigmaZ = 4.2 cm +# SigmaX = 11.8 um +# SigmaY = 5.5 um +# BS positions extracted from 2018B 3.8T data, run 316199, fill 6675 (from StreamExpressAlignment, HP BS): +# X0 = 0.09676 [cm] +# Y0 = -0.06245 [cm] +# Z0 = -0.292 [cm] +# BPIX absolute position (from https://cms-conddb.cern.ch/cmsDbBrowser/payload_inspector/Prod): +# X = 0.0859918 cm +# Y = -0.104172 cm +# Z = -0.327748 cm +Run3FlatOpticsGaussVtxSigmaZ4p2cmSmearingParameters = cms.PSet( + MeanX = cms.double(0.0107682), + MeanY = cms.double(0.041722), + MeanZ = cms.double(0.035748), + SigmaY = cms.double(0.00055), + SigmaX = cms.double(0.00118), + SigmaZ = cms.double(4.2), + TimeOffset = cms.double(0.0) +) +# Gaussian smearing +# Flat optics for Run3 - High SigmaZ +# SigmaZ = 5.3 cm +# SigmaX = 15 um +# SigmaY = 13 um +# BS positions extracted from 2018B 3.8T data, run 316199, fill 6675 (from StreamExpressAlignment, HP BS): +# X0 = 0.09676 [cm] +# Y0 = -0.06245 [cm] +# Z0 = -0.292 [cm] +# BPIX absolute position (from https://cms-conddb.cern.ch/cmsDbBrowser/payload_inspector/Prod): +# X = 0.0859918 cm +# Y = -0.104172 cm +# Z = -0.327748 cm +Run3FlatOpticsGaussVtxSigmaZ5p3cmSmearingParameters = cms.PSet( + MeanX = cms.double(0.0107682), + MeanY = cms.double(0.041722), + MeanZ = cms.double(0.035748), + SigmaY = cms.double(0.0013), + SigmaX = cms.double(0.0015), + SigmaZ = cms.double(5.3), + TimeOffset = cms.double(0.0) +) # Flat Smearing # Important note: flat independent distributions in Z and T are not correct for physics production @@ -622,6 +666,74 @@ Z0 = cms.double(0.035748 ) ) +# Run3 possible beam parameters +# Round optics - Low SigmaZ = 3.4 cm +# From 2018B 3.8T data +# BS parameters extracted from run 316199, fill 6675 (from StreamExpressAlignment, HP BS): +# X0 = 0.09676 [cm] +# Y0 = -0.06245 [cm] +# Z0 = -0.292 [cm] +# sigmaZ0 = 3.2676 [cm] +# BeamWidthX 0.0008050 +# BeamWidthY 0.0006238 +# +# set SigmaZ0 = 3.4 [cm] +# set BeamWidthX = BeamWidthY = 11.5 [um] +# set beta* = 28 cm +# energy = 13 TeV +# From LHC calculator, emittance is 4.762e-8 cm +# https://lpc.web.cern.ch/lpc/lumi2.html +# +# BPIX absolute position (from https://cms-conddb.cern.ch/cmsDbBrowser/payload_inspector/Prod): +# X = 0.0859918 cm +# Y = -0.104172 cm +# Z = -0.327748 cm +Run3RoundOptics25ns13TeVLowSigmaZVtxSmearingParameters = cms.PSet( + Phi = cms.double(0.0), + BetaStar = cms.double(28.0), + Emittance = cms.double(4.762e-8), + Alpha = cms.double(0.0), + SigmaZ = cms.double(3.4), + TimeOffset = cms.double(0.0), + X0 = cms.double(0.0107682), + Y0 = cms.double(0.041722 ), + Z0 = cms.double(0.035748 ) +) + +# Run3 possible beam parameters +# Round optics - High SigmaZ = 5.7 cm +# From 2018B 3.8T data +# BS parameters extracted from run 316199, fill 6675 (from StreamExpressAlignment, HP BS): +# X0 = 0.09676 [cm] +# Y0 = -0.06245 [cm] +# Z0 = -0.292 [cm] +# sigmaZ0 = 3.2676 [cm] +# BeamWidthX 0.0008050 +# BeamWidthY 0.0006238 +# +# set SigmaZ0 = 5.7 [cm] +# set BeamWidthX = BeamWidthY = 11.5 [um] +# set beta* = 28 cm +# energy = 13 TeV +# From LHC calculator, emittance is 4.762e-8 cm +# https://lpc.web.cern.ch/lpc/lumi2.html +# +# BPIX absolute position (from https://cms-conddb.cern.ch/cmsDbBrowser/payload_inspector/Prod): +# X = 0.0859918 cm +# Y = -0.104172 cm +# Z = -0.327748 cm +Run3RoundOptics25ns13TeVHighSigmaZVtxSmearingParameters = cms.PSet( + Phi = cms.double(0.0), + BetaStar = cms.double(28.0), + Emittance = cms.double(4.762e-8), + Alpha = cms.double(0.0), + SigmaZ = cms.double(5.7), + TimeOffset = cms.double(0.0), + X0 = cms.double(0.0107682), + Y0 = cms.double(0.041722 ), + Z0 = cms.double(0.035748 ) +) + # Test HF offset ShiftedCollision2015VtxSmearingParameters = cms.PSet( Phi = cms.double(0.0), diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ4p2cm_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ4p2cm_cfi.py new file mode 100644 index 0000000000000..8b13929913e4c --- /dev/null +++ b/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ4p2cm_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import Run3FlatOpticsGaussVtxSigmaZ4p2cmSmearingParameters,VtxSmearedCommon +VtxSmeared = cms.EDProducer("GaussEvtVtxGenerator", + Run3FlatOpticsGaussVtxSigmaZ4p2cmSmearingParameters, + VtxSmearedCommon +) diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ5p3cm_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ5p3cm_cfi.py new file mode 100644 index 0000000000000..dc665e349ac9a --- /dev/null +++ b/IOMC/EventVertexGenerators/python/VtxSmearedRun3FlatOpticsGaussSigmaZ5p3cm_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import Run3FlatOpticsGaussVtxSigmaZ5p3cmSmearingParameters,VtxSmearedCommon +VtxSmeared = cms.EDProducer("GaussEvtVtxGenerator", + Run3FlatOpticsGaussVtxSigmaZ5p3cmSmearingParameters, + VtxSmearedCommon +) diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVHighSigmaZ_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVHighSigmaZ_cfi.py new file mode 100644 index 0000000000000..d4522570b3832 --- /dev/null +++ b/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVHighSigmaZ_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import * +VtxSmeared = cms.EDProducer("BetafuncEvtVtxGenerator", + Run3RoundOptics25ns13TeVHighSigmaZVtxSmearingParameters, + VtxSmearedCommon +) \ No newline at end of file diff --git a/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVLowSigmaZ_cfi.py b/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVLowSigmaZ_cfi.py new file mode 100644 index 0000000000000..f718bc829f48f --- /dev/null +++ b/IOMC/EventVertexGenerators/python/VtxSmearedRun3RoundOptics25ns13TeVLowSigmaZ_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import * +VtxSmeared = cms.EDProducer("BetafuncEvtVtxGenerator", + Run3RoundOptics25ns13TeVLowSigmaZVtxSmearingParameters, + VtxSmearedCommon +) \ No newline at end of file diff --git a/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc new file mode 100644 index 0000000000000..8506da2b0e306 --- /dev/null +++ b/IOMC/EventVertexGenerators/src/BeamDivergenceVtxGenerator.cc @@ -0,0 +1,148 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class BeamDivergenceVtxGenerator : public edm::stream::EDProducer<> +{ + public: + explicit BeamDivergenceVtxGenerator(const edm::ParameterSet&); + ~BeamDivergenceVtxGenerator() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + + void produce(edm::Event&, const edm::EventSetup&) override; + + private: + edm::EDGetTokenT sourceToken_; + + bool simulateVertex_; + bool simulateBeamDivergence_; +}; + +//---------------------------------------------------------------------------------------------------- + +BeamDivergenceVtxGenerator::BeamDivergenceVtxGenerator(const edm::ParameterSet& iConfig) : + sourceToken_(consumes( iConfig.getParameter("src"))), + simulateVertex_ (iConfig.getParameter("simulateVertex")), + simulateBeamDivergence_(iConfig.getParameter("simulateBeamDivergence")) +{ + edm::Service rng; + if (!rng.isAvailable()) + throw cms::Exception("Configuration") + << "The BeamDivergenceVtxGenerator requires the RandomNumberGeneratorService\n" + "which is not present in the configuration file. \n" + "You must add the service\n" + "in the configuration file or remove the modules that require it."; + + produces(); +} + +//---------------------------------------------------------------------------------------------------- + +void +BeamDivergenceVtxGenerator::produce(edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get random engine + edm::Service rng; + CLHEP::HepRandomEngine* rnd = &(rng->getEngine(iEvent.streamID())); + + // get conditions + edm::ESHandle hBeamParameters; + iSetup.get().get(hBeamParameters); + + // get input + edm::Handle hepUnsmearedMCEvt; + iEvent.getByToken(sourceToken_, hepUnsmearedMCEvt); + + // prepare output + HepMC::GenEvent* genevt = new HepMC::GenEvent(*hepUnsmearedMCEvt->GetEvent()); + std::unique_ptr pEvent(new edm::HepMCProduct(genevt)); + + // apply vertex smearing + if (simulateVertex_) { + // NB: the separtion between effective offsets in LHC sectors 45 and 56 cannot be applied, thus the values for 45 are used + const double vtx_x = hBeamParameters->getVtxOffsetX45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevX(); + const double vtx_y = hBeamParameters->getVtxOffsetY45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevY(); + const double vtx_z = hBeamParameters->getVtxOffsetZ45() + CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getVtxStddevZ(); + + HepMC::FourVector shift(vtx_x*1E1, vtx_y*1E1, vtx_z*1E1, 0.); // conversions: cm to mm + pEvent->applyVtxGen(&shift); + } + + // apply beam divergence + if (simulateBeamDivergence_) { + const double bd_x_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX45(); + const double bd_x_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceX56(); + + const double bd_y_45 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY45(); + const double bd_y_56 = CLHEP::RandGauss::shoot(rnd) * hBeamParameters->getBeamDivergenceY56(); + + for (HepMC::GenEvent::particle_iterator part = genevt->particles_begin(); part != genevt->particles_end(); ++part) { + const HepMC::FourVector mom = (*part)->momentum(); + + // TODO: this is an oversimplified implemetation + // the TOTEM smearing module should be taken as reference + + double th_x = mom.x() / mom.z(); + double th_y = mom.y() / mom.z(); + + if (mom.z() > 0.) + { + th_x += bd_x_45; + th_y += bd_y_45; + } else { + th_x += bd_x_56; + th_y += bd_y_56; + } + + // calculate consistent p_z component + const double sign = (mom.z() > 0.) ? 1. : -1.; + const double p_z = sign * mom.rho() / sqrt(1. + th_x*th_x + th_y*th_y); + + // set smeared momentum + (*part)->set_momentum(HepMC::FourVector(p_z * th_x, p_z * th_y, p_z, mom.e())); + } + } + + // save output + iEvent.put(std::move(pEvent)); +} + +//---------------------------------------------------------------------------------------------------- + +void +BeamDivergenceVtxGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("generator", "unsmeared")) + ->setComment("input collection where to retrieve outgoing particles kinematics to be smeared"); + desc.add("simulateBeamDivergence", true)->setComment("account for the beam angular divergence?"); + desc.add("simulateVertex", true)->setComment("account for the vertex transverse smearing?"); + + descriptions.add("beamDivergenceVtxGenerator", desc); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(BeamDivergenceVtxGenerator); diff --git a/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc b/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc new file mode 100644 index 0000000000000..28ccec7edd7e2 --- /dev/null +++ b/IOMC/EventVertexGenerators/src/PassThroughEvtVtxGenerator.cc @@ -0,0 +1,67 @@ + +/* +*/ + +#include "IOMC/EventVertexGenerators/interface/PassThroughEvtVtxGenerator.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "FWCore/Utilities/interface/Exception.h" + +#include "DataFormats/Provenance/interface/Provenance.h" +#include "FWCore/Utilities/interface/EDMException.h" + +//#include "HepMC/GenEvent.h" +// #include "CLHEP/Vector/ThreeVector.h" +// #include "HepMC/SimpleVector.h" + +using namespace edm; +using namespace CLHEP; +//using namespace HepMC; + + +PassThroughEvtVtxGenerator::PassThroughEvtVtxGenerator( const ParameterSet& pset ) + : BaseEvtVtxGenerator(pset) +{ + Service rng; + if ( ! rng.isAvailable()) { + throw cms::Exception("Configuration") + << "The PassThroughEvtVtxGenerator requires the RandomNumberGeneratorService\n" + "which is not present in the configuration file. \n" + "You must add the service\n" + "in the configuration file or remove the modules that require it."; + } + sourceToken=consumes(pset.getParameter("src")); +} + +PassThroughEvtVtxGenerator::~PassThroughEvtVtxGenerator() +{ +} + +HepMC::FourVector PassThroughEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine*) const { + return HepMC::FourVector(0.,0.,0.); +} + +void PassThroughEvtVtxGenerator::produce( Event& evt, const EventSetup& ) +{ + edm::Service rng; + + Handle HepUnsmearedMCEvt ; + + evt.getByToken( sourceToken, HepUnsmearedMCEvt ) ; + + // Copy the HepMC::GenEvent + HepMC::GenEvent* genevt = new HepMC::GenEvent(*HepUnsmearedMCEvt->GetEvent()); + std::unique_ptr HepMCEvt(new edm::HepMCProduct(genevt)); + + evt.put(std::move(HepMCEvt)) ; + + return ; +} diff --git a/IOMC/EventVertexGenerators/src/module.cc b/IOMC/EventVertexGenerators/src/module.cc index 3ec6e2d985d45..3759a43fe2f48 100644 --- a/IOMC/EventVertexGenerators/src/module.cc +++ b/IOMC/EventVertexGenerators/src/module.cc @@ -3,6 +3,7 @@ //#include "IOMC/EventVertexGenerators/interface/VertexGenerator.h" #include "IOMC/EventVertexGenerators/interface/BaseEvtVtxGenerator.h" +#include "IOMC/EventVertexGenerators/interface/PassThroughEvtVtxGenerator.h" #include "IOMC/EventVertexGenerators/interface/GaussEvtVtxGenerator.h" #include "IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h" #include "IOMC/EventVertexGenerators/interface/BeamProfileVtxGenerator.h" @@ -18,6 +19,7 @@ //using edm::VertexGenerator; //DEFINE_FWK_MODULE(VertexGenerator) ; +DEFINE_FWK_MODULE(PassThroughEvtVtxGenerator) ; DEFINE_FWK_MODULE(GaussEvtVtxGenerator) ; DEFINE_FWK_MODULE(FlatEvtVtxGenerator) ; DEFINE_FWK_MODULE(BeamProfileVtxGenerator) ; diff --git a/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h new file mode 100644 index 0000000000000..f5e8755a40201 --- /dev/null +++ b/IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h @@ -0,0 +1,29 @@ +#ifndef IOMC_ParticleGun_CloseByParticleGunProducer_H +#define IOMC_ParticleGun_CloseByParticleGunProducer_H + +#include "IOMC/ParticleGuns/interface/BaseFlatGunProducer.h" + +namespace edm +{ + + class CloseByParticleGunProducer : public BaseFlatGunProducer + { + + public: + CloseByParticleGunProducer(const ParameterSet &); + ~CloseByParticleGunProducer() override; + + private: + + void produce(Event & e, const EventSetup& es) override; + + protected : + + // data members + double fEn,fR,fZ,fDelta; + bool fPointing = false; + std::vector fPartIDs; + }; +} + +#endif diff --git a/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h new file mode 100644 index 0000000000000..4e67c7632cf7e --- /dev/null +++ b/IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#ifndef RandomXiThetaGunProducer_H +#define RandomXiThetaGunProducer_H + +#include "FWCore/Framework/interface/one/EDProducer.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Random/RandGauss.h" + +namespace CLHEP { class HepRandomEngine; } +namespace edm { + +class RandomXiThetaGunProducer : public one::EDProducer<> +{ + public: + RandomXiThetaGunProducer(const ParameterSet&); + ~RandomXiThetaGunProducer() override = default; + + private: + void produce(Event&, const EventSetup&) override; + void generateParticle(double z_sign, double mass, unsigned int barcode, HepMC::GenVertex *vtx) const; + + unsigned int verbosity_; + unsigned int particleId_; + + double energy_; + double xi_min_, xi_max_; + double theta_x_mean_, theta_x_sigma_; + double theta_y_mean_, theta_y_sigma_; + + unsigned int nParticlesSector45_; + unsigned int nParticlesSector56_; + + CLHEP::HepRandomEngine* engine_; +}; + +} + +#endif diff --git a/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc new file mode 100644 index 0000000000000..1de060edcf189 --- /dev/null +++ b/IOMC/ParticleGuns/src/CloseByParticleGunProducer.cc @@ -0,0 +1,125 @@ +#include + +#include "IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" + +#include "DataFormats/Math/interface/Vector3D.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "CLHEP/Random/RandFlat.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Random/RandFlat.h" + +using namespace edm; +using namespace std; + +CloseByParticleGunProducer::CloseByParticleGunProducer(const ParameterSet& pset) : + BaseFlatGunProducer(pset) +{ + + ParameterSet defpset ; + ParameterSet pgun_params = + pset.getParameter("PGunParameters") ; + + fEn = pgun_params.getParameter("En"); + fR = pgun_params.getParameter("R"); + fZ = pgun_params.getParameter("Z"); + fDelta = pgun_params.getParameter("Delta"); + fPartIDs = pgun_params.getParameter< vector >("PartID"); + fPointing = pgun_params.getParameter("Pointing"); + + produces("unsmeared"); + produces(); +} + +CloseByParticleGunProducer::~CloseByParticleGunProducer() +{ + // no need to cleanup GenEvent memory - done in HepMCProduct +} + +void CloseByParticleGunProducer::produce(Event &e, const EventSetup& es) +{ + edm::Service rng; + CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); + + if ( fVerbosity > 0 ) + { + LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Begin New Event Generation" << endl ; + } + fEvt = new HepMC::GenEvent() ; + + // loop over particles + // + int barcode = 1 ; + double phi = CLHEP::RandFlat::shoot(engine, -3.14159265358979323846, 3.14159265358979323846); + for (unsigned int ip=0; ipparticle(HepPDT::ParticleID(abs(PartID))) ; + double mass = PData->mass().value() ; + double mom = sqrt(fEn*fEn-mass*mass); + double px = 0.; + double py = 0.; + double pz = mom; + double energy = fEn; + + // Compute Vertex Position + double x=fR*cos(phi); + double y=fR*sin(phi); + constexpr double c= 2.99792458e+1; // cm/ns + double timeOffset = sqrt(x*x + y*y + fZ*fZ)/c*ns*c_light; + HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(x*cm,y*cm,fZ*cm,timeOffset)); + + HepMC::FourVector p(px,py,pz,energy) ; + // If we are requested to be pointing to (0,0,0), correct the momentum direction + if (fPointing) { + math::XYZVector direction(x,y,fZ); + math::XYZVector momentum = direction.unit() * mom; + p.setX(momentum.x()); + p.setY(momentum.y()); + p.setZ(momentum.z()); + } + HepMC::GenParticle* Part = new HepMC::GenParticle(p,PartID,1); + Part->suggest_barcode( barcode ); + barcode++; + + Vtx->add_particle_out(Part); + + if (fVerbosity > 0) { + Vtx->print(); + Part->print(); + } + fEvt->add_vertex(Vtx); + } + + + fEvt->set_event_number(e.id().event()); + fEvt->set_signal_process_id(20); + + if ( fVerbosity > 0 ) + { + fEvt->print(); + } + + unique_ptr BProduct(new HepMCProduct()); + BProduct->addHepMCData( fEvt ); + e.put(std::move(BProduct), "unsmeared"); + + unique_ptr genEventInfo(new GenEventInfoProduct(fEvt)); + e.put(std::move(genEventInfo)); + + if ( fVerbosity > 0 ) + { + LogDebug("CloseByParticleGunProducer") << " CloseByParticleGunProducer : Event Generation Done " << endl; + } +} + diff --git a/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc new file mode 100644 index 0000000000000..2db3f41fce5e1 --- /dev/null +++ b/IOMC/ParticleGuns/src/RandomXiThetaGunProducer.cc @@ -0,0 +1,106 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Utilities/interface/RandomNumberGenerator.h" + +#include "HepPDT/ParticleDataTable.hh" +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +using namespace edm; +using namespace std; + +//---------------------------------------------------------------------------------------------------- + +RandomXiThetaGunProducer::RandomXiThetaGunProducer(const edm::ParameterSet& iConfig) : + verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), + particleId_ (iConfig.getParameter("particleId")), + energy_ (iConfig.getParameter("energy")), + xi_min_ (iConfig.getParameter("xi_min")), + xi_max_ (iConfig.getParameter("xi_max")), + theta_x_mean_ (iConfig.getParameter("theta_x_mean")), + theta_x_sigma_ (iConfig.getParameter("theta_x_sigma")), + theta_y_mean_ (iConfig.getParameter("theta_y_mean")), + theta_y_sigma_ (iConfig.getParameter("theta_y_sigma")), + nParticlesSector45_(iConfig.getParameter("nParticlesSector45")), + nParticlesSector56_(iConfig.getParameter("nParticlesSector56")), + engine_(nullptr) +{ + produces("unsmeared"); +} + +//---------------------------------------------------------------------------------------------------- + +void RandomXiThetaGunProducer::produce(edm::Event &e, const edm::EventSetup& es) +{ + // get conditions + edm::Service rng; + engine_ = &rng->getEngine(e.streamID()); + + ESHandle pdgTable; + es.getData(pdgTable); + + // prepare HepMC event + HepMC::GenEvent *fEvt = new HepMC::GenEvent(); + fEvt->set_event_number(e.id().event()); + + HepMC::GenVertex *vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0., 0.)); + fEvt->add_vertex(vtx); + + const HepPDT::ParticleData *pData = pdgTable->particle(HepPDT::ParticleID(particleId_)); + double mass = pData->mass().value(); + + // generate particles + unsigned int barcode = 0; + + for (unsigned int i = 0; i < nParticlesSector45_; ++i) + generateParticle(+1., mass, ++barcode, vtx); + + for (unsigned int i = 0; i < nParticlesSector56_; ++i) + generateParticle(-1., mass, ++barcode, vtx); + + // save output + std::unique_ptr output(new HepMCProduct()) ; + output->addHepMCData(fEvt); + e.put(std::move(output), "unsmeared"); +} + +//---------------------------------------------------------------------------------------------------- + +void RandomXiThetaGunProducer::generateParticle(double z_sign, double mass, unsigned int barcode, + HepMC::GenVertex *vtx) const +{ + const double xi = CLHEP::RandFlat::shoot(engine_, xi_min_, xi_max_); + const double theta_x = CLHEP::RandGauss::shoot(engine_, theta_x_mean_, theta_x_sigma_); + const double theta_y = CLHEP::RandGauss::shoot(engine_, theta_y_mean_, theta_y_sigma_); + + if (verbosity_) + LogInfo("RandomXiThetaGunProducer") << "xi = " << xi << ", theta_x = " << theta_x + << ", theta_y" << theta_y << ", z_sign = " << z_sign; + + const double cos_theta = sqrt(1. - theta_x*theta_x - theta_y*theta_y); + + const double p_nom = sqrt(energy_*energy_ - mass*mass); + const double p = p_nom * (1. - xi); + const double e = sqrt(p*p + mass*mass); + + HepMC::FourVector momentum( + p * theta_x, + p * theta_y, + z_sign * p * cos_theta, + e + ); + + HepMC::GenParticle* particle = new HepMC::GenParticle(momentum, particleId_, 1); + particle->suggest_barcode(barcode); + vtx->add_particle_out(particle); +} diff --git a/IOMC/ParticleGuns/src/SealModule.cc b/IOMC/ParticleGuns/src/SealModule.cc index 57de81937405e..140c401a7e717 100644 --- a/IOMC/ParticleGuns/src/SealModule.cc +++ b/IOMC/ParticleGuns/src/SealModule.cc @@ -19,12 +19,12 @@ #include "IOMC/ParticleGuns/interface/RandomtXiGunProducer.h" #include "IOMC/ParticleGuns/interface/FlatRandomPtAndDxyGunProducer.h" #include "IOMC/ParticleGuns/interface/RandomMultiParticlePGunProducer.h" - +#include "IOMC/ParticleGuns/interface/CloseByParticleGunProducer.h" +#include "IOMC/ParticleGuns/interface/RandomXiThetaGunProducer.h" // particle gun prototypes // - - + /* using edm::FlatEGunASCIIWriter; DEFINE_FWK_MODULE(FlatEGunASCIIWriter); @@ -58,3 +58,7 @@ using edm::FlatRandomPtAndDxyGunProducer; DEFINE_FWK_MODULE(FlatRandomPtAndDxyGunProducer); using edm::RandomMultiParticlePGunProducer; DEFINE_FWK_MODULE(RandomMultiParticlePGunProducer); +using edm::CloseByParticleGunProducer; +DEFINE_FWK_MODULE(CloseByParticleGunProducer); +using edm::RandomXiThetaGunProducer; +DEFINE_FWK_MODULE(RandomXiThetaGunProducer); diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h similarity index 99% rename from L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h index 5c82c9a256742..626ebddbc978a 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h @@ -37,7 +37,7 @@ #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h" #include "CondFormats/CSCObjects/interface/CSCDBL1TPParameters.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h" #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h similarity index 94% rename from L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h index c06462bcb0d05..0322333e2d902 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h @@ -7,8 +7,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUT.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUTGenerator.h" class CSCBaseboard { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h similarity index 99% rename from L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h index 171e983e52da6..2448cd5e1f531 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h @@ -34,7 +34,7 @@ #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCLCTPreTriggerDigi.h" #include "CondFormats/CSCObjects/interface/CSCDBL1TPParameters.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h" #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCComparatorDigiFitter.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCComparatorDigiFitter.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h similarity index 99% rename from L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h index 3d227e3bec9e1..ec58589bb164f 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h @@ -12,8 +12,8 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h" -#include "L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/GEMCoPadProcessor.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMCoPadDigiCollection.h" diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME11.h similarity index 97% rename from L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME11.h index aa16313ee7c70..7ad99e96727e2 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME11.h @@ -11,7 +11,7 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h" class CSCGEMMotherboardME11 : public CSCGEMMotherboard { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME21.h similarity index 96% rename from L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME21.h index 9b023a1e11c15..cae89a1dacb24 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME21.h @@ -11,7 +11,7 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h" class CSCGEMMotherboardME21 : public CSCGEMMotherboard { diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCLayerInfo.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCLayerInfo.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/test/CSCLayerInfo.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCLayerInfo.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h similarity index 96% rename from L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h index 588f8e07f9f4d..43ad0db5726de 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h @@ -34,10 +34,10 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h" class CSCMotherboard : public CSCBaseboard { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboardME11.h similarity index 96% rename from L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboardME11.h index 39e7501527c25..128748f051b81 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboardME11.h @@ -13,7 +13,7 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h" class CSCMotherboardME11 : public CSCUpgradeMotherboard { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCMuonPortCard.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCMuonPortCard.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h similarity index 95% rename from L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h index f53d18d835cfd..81da7753d5376 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h @@ -11,7 +11,7 @@ * Updates for high pileup running by Vadim Khotilovich (TAMU), December 2012 */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h" class CSCUpgradeAnodeLCTProcessor : public CSCAnodeLCTProcessor { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeCathodeLCTProcessor.h similarity index 96% rename from L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeCathodeLCTProcessor.h index 4b16fec0295ff..d70c6d17b8e00 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeCathodeLCTProcessor.h @@ -17,7 +17,7 @@ * Removing usage of outdated class CSCTriggerGeometry by Sven Dildick (TAMU) */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h" #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h similarity index 95% rename from L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h index 7920785a23dd0..8af4fb05f5159 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h @@ -10,9 +10,9 @@ * */ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeCathodeLCTProcessor.h" // generic container type namespace{ diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUT.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUT.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUTGenerator.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.h rename to L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUTGenerator.h diff --git a/L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/GEMCoPadProcessor.h similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.h rename to L1Trigger/CSCTriggerPrimitives/interface/GEMCoPadProcessor.h diff --git a/L1Trigger/CSCTriggerPrimitives/plugins/BuildFile.xml b/L1Trigger/CSCTriggerPrimitives/plugins/BuildFile.xml index 13afb39f43734..8d4f1de995023 100644 --- a/L1Trigger/CSCTriggerPrimitives/plugins/BuildFile.xml +++ b/L1Trigger/CSCTriggerPrimitives/plugins/BuildFile.xml @@ -1,6 +1,20 @@ - + + + + + + + + + + + + + + + diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.cc b/L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.cc similarity index 98% rename from L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.cc rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.cc index 1772dd0481ce2..11e9ed93a7ac4 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.cc +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.cc @@ -14,8 +14,8 @@ #include "Geometry/CSCGeometry/interface/CSCLayer.h" #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h" -#include "L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.h" using namespace std; diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.h b/L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.h similarity index 92% rename from L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.h rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.h index fff495a3cda6a..bbb9613189f35 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.h +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.h @@ -11,13 +11,13 @@ * */ -#ifndef CSCTriggerPrimitives_CSCAnodeLCTAnalyzer_H -#define CSCTriggerPrimitives_CSCAnodeLCTAnalyzer_H +#ifndef L1Trigger_CSCTriggerPrimitives_CSCAnodeLCTAnalyzer_H +#define L1Trigger_CSCTriggerPrimitives_CSCAnodeLCTAnalyzer_H #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include "L1Trigger/CSCTriggerPrimitives/test/CSCLayerInfo.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCLayerInfo.h" typedef CSCLayerInfo CSCAnodeLayerInfo; diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.cc b/L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.cc similarity index 99% rename from L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.cc rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.cc index 710e989337972..5b2d2e91bda9c 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.cc +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.cc @@ -14,8 +14,8 @@ #include "Geometry/CSCGeometry/interface/OffsetRadialStripTopology.h" #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h" -#include "L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.h" using namespace std; diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.h b/L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.h similarity index 93% rename from L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.h rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.h index 4dad073c6c35d..449121fb61261 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.h +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.h @@ -11,13 +11,13 @@ * */ -#ifndef CSCTriggerPrimitives_CSCCathodeLCTAnalyzer_H -#define CSCTriggerPrimitives_CSCCathodeLCTAnalyzer_H +#ifndef L1Trigger_CSCTriggerPrimitives_CSCCathodeLCTAnalyzer_H +#define L1Trigger_CSCTriggerPrimitives_CSCCathodeLCTAnalyzer_H #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" -#include "L1Trigger/CSCTriggerPrimitives/test/CSCLayerInfo.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCLayerInfo.h" typedef CSCLayerInfo CSCCathodeLayerInfo; diff --git a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc index da20c95a6250b..02c6fd77a6121 100644 --- a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.cc @@ -13,7 +13,7 @@ //-------------------------------------------------- #include "L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" diff --git a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h index e4693e77c23af..6cc10abfbdf3e 100644 --- a/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesProducer.h @@ -39,7 +39,7 @@ #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h" class CSCTriggerPrimitivesProducer : public edm::global::EDProducer> { diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.cc b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.cc similarity index 99% rename from L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.cc rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.cc index a4549e0f653ec..ff0b06de6dbe8 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.cc +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.cc @@ -15,7 +15,7 @@ //----------------------- // This Class's Header -- //----------------------- -#include "CSCTriggerPrimitivesReader.h" +#include "L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.h" //------------------------------- // Collaborating Class Headers -- @@ -36,8 +36,8 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" // MC tests -#include "L1Trigger/CSCTriggerPrimitives/test/CSCAnodeLCTAnalyzer.h" -#include "L1Trigger/CSCTriggerPrimitives/test/CSCCathodeLCTAnalyzer.h" +#include "L1Trigger/CSCTriggerPrimitives/plugins/CSCAnodeLCTAnalyzer.h" +#include "L1Trigger/CSCTriggerPrimitives/plugins/CSCCathodeLCTAnalyzer.h" #include "Geometry/CSCGeometry/interface/CSCLayer.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.h b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.h similarity index 98% rename from L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.h rename to L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.h index 7f240a05f2749..78a6017bca4cc 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader.h +++ b/L1Trigger/CSCTriggerPrimitives/plugins/CSCTriggerPrimitivesReader.h @@ -1,5 +1,5 @@ -#ifndef CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h -#define CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h +#ifndef L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h +#define L1Trigger_CSCTriggerPrimitives_CSCTriggerPrimitivesReader_h /** \class CSCTriggerPrimitivesReader * @@ -28,7 +28,7 @@ #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h" // TMB07 +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h" // TMB07 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" diff --git a/L1Trigger/CSCTriggerPrimitives/test/L1CSCTPEmulatorConfigAnalyzer.cc b/L1Trigger/CSCTriggerPrimitives/plugins/L1CSCTPEmulatorConfigAnalyzer.cc similarity index 100% rename from L1Trigger/CSCTriggerPrimitives/test/L1CSCTPEmulatorConfigAnalyzer.cc rename to L1Trigger/CSCTriggerPrimitives/plugins/L1CSCTPEmulatorConfigAnalyzer.cc diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfi.py b/L1Trigger/CSCTriggerPrimitives/python/CSCTriggerPrimitivesReader_cfi.py similarity index 97% rename from L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfi.py rename to L1Trigger/CSCTriggerPrimitives/python/CSCTriggerPrimitivesReader_cfi.py index cc61b4194fe19..24f24bf36f777 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfi.py +++ b/L1Trigger/CSCTriggerPrimitives/python/CSCTriggerPrimitivesReader_cfi.py @@ -6,7 +6,7 @@ # ===================================================== lctreader = cms.EDAnalyzer("CSCTriggerPrimitivesReader", # Parameters common for all boards - commonParam = cscTriggerPrimitiveDigis.commonParam + commonParam = cscTriggerPrimitiveDigis.commonParam, # Switch on/off the verbosity and turn on/off histogram production debug = cms.untracked.bool(False), # Define which LCTs are present in the input file. This will determine the diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc index 6cede540056a2..a1c57f1d9c321 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h" #include //----------------- diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc index 5126af093441f..e4efe5f026e0b 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h" CSCBaseboard::CSCBaseboard(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc index 64b9c6aaa9d0b..4e368f6d28541 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCCathodeLCTProcessor.h" #include #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.cc index 2c808f8d4456a..60b53548d623b 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCComparatorDigiFitter.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCComparatorDigiFitter.h" #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" #include "DataFormats/Math/interface/normalizedPhi.h" diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc index 2f9237c600788..7618ee65c447e 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboard.h" CSCGEMMotherboard::CSCGEMMotherboard(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.cc index 4d6902f9fd2a3..2482a6e7beab1 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME11.h" CSCGEMMotherboardME11::CSCGEMMotherboardME11(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.cc index 83fbc7a3c9f34..0d80cb8107e31 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME21.h" CSCGEMMotherboardME21::CSCGEMMotherboardME21(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc index 37f74cd4a1d27..a44717daff425 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h" #include // Default values of configuration parameters. diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.cc index 0abaa8deaf4a9..8d1f9b38187a6 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.cc @@ -10,7 +10,7 @@ // //----------------------------------------------------------------------------- -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboardME11.h" CSCMotherboardME11::CSCMotherboardME11(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.cc index 405d26f7c1f47..cb2a429f5fd43 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMuonPortCard.h" #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc index 03c6bdeeb5725..b86059c966ccf 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc @@ -1,9 +1,9 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME11.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME11.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboardME21.h" -#include "L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboardME11.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME11.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCGEMMotherboardME21.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCMuonPortCard.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" const int CSCTriggerPrimitivesBuilder::min_endcap = CSCDetId::minEndcapId(); diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.cc index 3a105817f7c0e..5dbe2c3964ff0 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeAnodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeAnodeLCTProcessor.h" CSCUpgradeAnodeLCTProcessor::CSCUpgradeAnodeLCTProcessor(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.cc index d8de4f8217da7..a6eefaf219d95 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeCathodeLCTProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeCathodeLCTProcessor.h" #include #include diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.cc index ca89d4ef52a96..4ff9c5366f816 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboard.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboard.h" CSCUpgradeMotherboard::LCTContainer::LCTContainer(unsigned int trig_window_size) : match_trig_window_size_(trig_window_size) diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.cc index 6d14e516b3404..dc8ac95491a1c 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUT.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUT.h" CSCMotherboardLUTME11::CSCMotherboardLUTME11() { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.cc index 07fc41dda1bf2..14166c5422cdd 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/CSCUpgradeMotherboardLUTGenerator.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/CSCUpgradeMotherboardLUTGenerator.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc index 564c400b5faf5..68096f2776696 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.h" +#include "L1Trigger/CSCTriggerPrimitives/interface/GEMCoPadProcessor.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include diff --git a/L1Trigger/CSCTriggerPrimitives/test/BuildFile.xml b/L1Trigger/CSCTriggerPrimitives/test/BuildFile.xml deleted file mode 100644 index 8cdaf6389700e..0000000000000 --- a/L1Trigger/CSCTriggerPrimitives/test/BuildFile.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfg.py b/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfg.py index 23b4d78af66c9..55c6efb07df7a 100644 --- a/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfg.py +++ b/L1Trigger/CSCTriggerPrimitives/test/CSCTriggerPrimitivesReader_cfg.py @@ -45,7 +45,7 @@ fileName = cms.string('TPEHists.root') ) -process.load("CSCTriggerPrimitivesReader_cfi") +process.load("L1Trigger.CSCTriggerPrimitives.CSCTriggerPrimitivesReader_cfi") process.lctreader.debug = True process.p = cms.Path(process.lctreader) diff --git a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc b/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc index 48febf71110da..fc9be6adecca4 100644 --- a/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc +++ b/L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc @@ -12,7 +12,6 @@ #include "TrackPropagation/RungeKutta/interface/defaultRKPropagator.h" #include "TrackPropagation/RungeKutta/interface/RKPropagatorInS.h" #include "FastSimulation/Event/interface/FSimEvent.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" #include "SimGeneral/HepPDTRecord/interface/PDTRecord.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -296,7 +295,6 @@ fill(const edm::Event& iEvent, const edm::EventSetup& es) triggerTools_.eventSetup(es); // This balck magic is needed to use the mySimEvent_ - ParticleTable::Sentry ptable(mySimEvent_->theTable()); edm::Handle hevH; edm::Handle> simTracksHandle; edm::Handle> simVerticesHandle; diff --git a/L1Trigger/L1THGCal/python/customTriggerGeometry.py b/L1Trigger/L1THGCal/python/customTriggerGeometry.py index 6d32f2e4d678c..1fd03fc8361cf 100644 --- a/L1Trigger/L1THGCal/python/customTriggerGeometry.py +++ b/L1Trigger/L1THGCal/python/customTriggerGeometry.py @@ -7,8 +7,8 @@ def custom_geometry_V9(process, implementation=1): if implementation==1: process.hgcalTriggerGeometryESProducer.TriggerGeometry.TriggerGeometryName = cms.string('HGCalTriggerGeometryV9Imp1') process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TCellsMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_mapping_8inch_aligned_192_432_V9_1.txt") - process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TWafersMapping = cms.FileInPath("L1Trigger/L1THGCal/data/wafer_mapping_V9_1.txt") - process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/panel_mapping_tdr_0.txt") + process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TWafersMapping = cms.FileInPath("L1Trigger/L1THGCal/data/wafer_mapping_V9_2.txt") + process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/panel_mapping_tdr_1.txt") process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TCellNeighborsMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_neighbor_mapping_8inch_aligned_192_432_0.txt") process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TCellsSciMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_mapping_sci_2x2_V9_1.txt") process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TCellNeighborsSciMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_neighbor_mapping_sci_2x2_V9_1.txt") @@ -17,7 +17,7 @@ def custom_geometry_V9(process, implementation=1): process.hgcalTriggerGeometryESProducer.TriggerGeometry.TriggerGeometryName = cms.string('HGCalTriggerGeometryV9Imp2') process.hgcalTriggerGeometryESProducer.TriggerGeometry.ScintillatorTriggerCellSize = cms.uint32(2) process.hgcalTriggerGeometryESProducer.TriggerGeometry.ScintillatorModuleSize = cms.uint32(12) - process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/panel_mapping_V9_tdr_0.txt") + process.hgcalTriggerGeometryESProducer.TriggerGeometry.L1TModulesMapping = cms.FileInPath("L1Trigger/L1THGCal/data/panel_mapping_V9_tdr_1.txt") process.hgcalConcentratorProducer.ProcessorParameters.MaxCellsInModule = cms.uint32(288) return process diff --git a/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc b/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc index 97cb91dc70017..052543ac3e641 100644 --- a/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc +++ b/L1Trigger/L1TMuonOverlap/src/GhostBusterPreferRefDt.cc @@ -20,6 +20,9 @@ std::vector GhostBusterPreferRefDt::select(std::vector muons // sorting within GB. auto customLess = [&](const AlgoMuon& a, const AlgoMuon& b)->bool { + // protect against access violation + if(a.getRefLayer() == -1 || b.getRefLayer() == -1) + return false; int aRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[a.getRefLayer()]; int bRefLayerLogicNum = omtfConfig->getRefToLogicNumber()[b.getRefLayer()]; if(a.getQ() > b.getQ()) diff --git a/L1Trigger/ME0Trigger/src/ME0Motherboard.h b/L1Trigger/ME0Trigger/interface/ME0Motherboard.h similarity index 100% rename from L1Trigger/ME0Trigger/src/ME0Motherboard.h rename to L1Trigger/ME0Trigger/interface/ME0Motherboard.h diff --git a/L1Trigger/ME0Trigger/src/ME0TriggerBuilder.h b/L1Trigger/ME0Trigger/interface/ME0TriggerBuilder.h similarity index 100% rename from L1Trigger/ME0Trigger/src/ME0TriggerBuilder.h rename to L1Trigger/ME0Trigger/interface/ME0TriggerBuilder.h diff --git a/L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.h b/L1Trigger/ME0Trigger/interface/ME0TriggerPseudoBuilder.h similarity index 100% rename from L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.h rename to L1Trigger/ME0Trigger/interface/ME0TriggerPseudoBuilder.h diff --git a/L1Trigger/ME0Trigger/plugins/ME0TriggerProducer.cc b/L1Trigger/ME0Trigger/plugins/ME0TriggerProducer.cc index f5e5f9115899c..95547f8ed0ca0 100644 --- a/L1Trigger/ME0Trigger/plugins/ME0TriggerProducer.cc +++ b/L1Trigger/ME0Trigger/plugins/ME0TriggerProducer.cc @@ -1,5 +1,5 @@ #include "L1Trigger/ME0Trigger/plugins/ME0TriggerProducer.h" -#include "L1Trigger/ME0Trigger/src/ME0TriggerBuilder.h" +#include "L1Trigger/ME0Trigger/interface/ME0TriggerBuilder.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/L1Trigger/ME0Trigger/plugins/ME0TriggerPseudoProducer.cc b/L1Trigger/ME0Trigger/plugins/ME0TriggerPseudoProducer.cc index 444b871c351e9..d10b2125721f1 100644 --- a/L1Trigger/ME0Trigger/plugins/ME0TriggerPseudoProducer.cc +++ b/L1Trigger/ME0Trigger/plugins/ME0TriggerPseudoProducer.cc @@ -1,5 +1,5 @@ #include "L1Trigger/ME0Trigger/plugins/ME0TriggerPseudoProducer.h" -#include "L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.h" +#include "L1Trigger/ME0Trigger/interface/ME0TriggerPseudoBuilder.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" diff --git a/L1Trigger/ME0Trigger/src/ME0Motherboard.cc b/L1Trigger/ME0Trigger/src/ME0Motherboard.cc index 683b952c07094..19b39eecfaa2e 100644 --- a/L1Trigger/ME0Trigger/src/ME0Motherboard.cc +++ b/L1Trigger/ME0Trigger/src/ME0Motherboard.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/ME0Trigger/src/ME0Motherboard.h" +#include "L1Trigger/ME0Trigger/interface/ME0Motherboard.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" diff --git a/L1Trigger/ME0Trigger/src/ME0TriggerBuilder.cc b/L1Trigger/ME0Trigger/src/ME0TriggerBuilder.cc index ea0ae8ade442a..2abe2a243416e 100644 --- a/L1Trigger/ME0Trigger/src/ME0TriggerBuilder.cc +++ b/L1Trigger/ME0Trigger/src/ME0TriggerBuilder.cc @@ -1,5 +1,5 @@ -#include "L1Trigger/ME0Trigger/src/ME0TriggerBuilder.h" -#include "L1Trigger/ME0Trigger/src/ME0Motherboard.h" +#include "L1Trigger/ME0Trigger/interface/ME0TriggerBuilder.h" +#include "L1Trigger/ME0Trigger/interface/ME0Motherboard.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" diff --git a/L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc b/L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc index 35f04fcd74490..d071340e6fc24 100644 --- a/L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc +++ b/L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc @@ -1,4 +1,4 @@ -#include "L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.h" +#include "L1Trigger/ME0Trigger/interface/ME0TriggerPseudoBuilder.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" diff --git a/L1TriggerConfig/DTTPGConfig/src/DTConfigLUTs.cc b/L1TriggerConfig/DTTPGConfig/src/DTConfigLUTs.cc index e47f27671e9fa..27eb586602822 100644 --- a/L1TriggerConfig/DTTPGConfig/src/DTConfigLUTs.cc +++ b/L1TriggerConfig/DTTPGConfig/src/DTConfigLUTs.cc @@ -124,8 +124,8 @@ DTConfigLUTs::DSPtoIEEE32(short DSPmantissa, short DSPexp, float *f) const void DTConfigLUTs::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp) const { - long int *pl=nullptr, lm; - bool sign=false; + long int pl=0; + static_assert(sizeof(decltype(pl)) >= sizeof(float)); DSPmantissa = 0; DSPexp = 0; @@ -133,13 +133,14 @@ DTConfigLUTs::IEEE32toDSP(float f, short int & DSPmantissa, short int & DSPexp) if( f!=0.0 ) { //pl = (long *)&f; - memcpy(pl,&f,sizeof(float)); - if((*pl & 0x80000000)!=0) + memcpy(&pl,&f,sizeof(float)); + bool sign=false; + if((pl & 0x80000000)!=0) sign=true; - lm = ( 0x800000 | (*pl & 0x7FFFFF)); // [1][23bit mantissa] + long int lm = ( 0x800000 | (pl & 0x7FFFFF)); // [1][23bit mantissa] lm >>= 9; //reduce to 15bits lm &= 0x7FFF; - DSPexp = ((*pl>>23)&0xFF)-126; + DSPexp = ((pl>>23)&0xFF)-126; DSPmantissa = (short)lm; if(sign) DSPmantissa = - DSPmantissa; // convert negative value in 2.s complement diff --git a/PhysicsTools/CondLiteIO/test/IntProductESSource.cc b/PhysicsTools/CondLiteIO/test/IntProductESSource.cc index 3a62f9ff367e3..f5e033e032403 100644 --- a/PhysicsTools/CondLiteIO/test/IntProductESSource.cc +++ b/PhysicsTools/CondLiteIO/test/IntProductESSource.cc @@ -77,7 +77,7 @@ IntProductESSource::produce(const IntProductRecord&) { auto data = std::make_unique(); data->value = nCalls_; ++nCalls_; - return std::move(data); + return data; } diff --git a/PhysicsTools/HepMCCandAlgos/plugins/MCMatchCandRefSelector.cc b/PhysicsTools/HepMCCandAlgos/plugins/MCMatchCandRefSelector.cc index 4400f044d7da2..baeb62f0c7d1e 100644 --- a/PhysicsTools/HepMCCandAlgos/plugins/MCMatchCandRefSelector.cc +++ b/PhysicsTools/HepMCCandAlgos/plugins/MCMatchCandRefSelector.cc @@ -24,7 +24,7 @@ namespace reco { bool operator()(const CandidateBaseRef &) const; private: EDGetTokenT srcToken_; - const GenParticleMatch * match_; + const GenParticleMatch * match_ = nullptr; }; void MCMatchCandRefSelector::newEvent(const Event& evt, const EventSetup&) { diff --git a/PhysicsTools/NanoAOD/plugins/IsFromLostTrackMapProducer.cc b/PhysicsTools/NanoAOD/plugins/IsFromLostTrackMapProducer.cc index 77dad6a54b9a5..dec89a3bd6596 100644 --- a/PhysicsTools/NanoAOD/plugins/IsFromLostTrackMapProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/IsFromLostTrackMapProducer.cc @@ -122,9 +122,7 @@ void IsFromLostTrackMapProducer::fillDescriptions(edm::ConfigurationDescriptions desc.add("packedPFCandidates")->setComment("packed PF Candidates collection "); desc.add("lostTracks")->setComment("lost tracks collection"); - std::string modname; - modname="isFromLostTrack map producer"; - descriptions.add(modname,desc); + descriptions.addWithDefaultLabel(desc); } diff --git a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py index 11b054c40ef72..9a3a9a76f314b 100644 --- a/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_updatedMVAIds_cff.py @@ -15,7 +15,6 @@ loadMVAfromDB = cms.bool(True), mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"), # name of the training you want to use mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - requireDecayMode = cms.bool(True), verbosity = cms.int32(0) ) # VVLoose WP @@ -71,7 +70,6 @@ loadMVAfromDB = cms.bool(True), mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"), # name of the training you want to use mvaOpt = cms.string("DBnewDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - requireDecayMode = cms.bool(True), verbosity = cms.int32(0) ) # VVLoose WP @@ -127,7 +125,6 @@ loadMVAfromDB = cms.bool(True), mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"), # name of the training you want to use mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - requireDecayMode = cms.bool(True), srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'), srcFootprintCorrection = cms.string('footprintCorrectiondR03'), srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'), @@ -189,7 +186,6 @@ loadMVAfromDB = cms.bool(True), mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), # name of the training you want to use mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - requireDecayMode = cms.bool(True), verbosity = cms.int32(0) ) # VVLoose WP @@ -246,7 +242,6 @@ loadMVAfromDB = cms.bool(True), mvaName = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), # name of the training you want to use mvaOpt = cms.string("DBoldDMwLT"), # option you want to use for your training (i.e., which variables are used to compute the BDT score) - requireDecayMode = cms.bool(True), verbosity = cms.int32(0) ) # VLoose WP diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc index 7494279fb299e..6a61e358e5653 100755 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc @@ -154,11 +154,13 @@ PATMuonProducer::PATMuonProducer(const edm::ParameterSet & iConfig, PATMuonHeavy //for mini-isolation calculation computeMiniIso_ = iConfig.getParameter("computeMiniIso"); + computePuppiCombinedIso_ = iConfig.getParameter("computePuppiCombinedIso"); + miniIsoParams_ = iConfig.getParameter >("miniIsoParams"); if(computeMiniIso_ && miniIsoParams_.size() != 9){ throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 9 elements.\n"; } - if(computeMiniIso_) + if(computeMiniIso_ || computePuppiCombinedIso_) pcToken_ = consumes(iConfig.getParameter("pfCandsForMiniIso")); // standard selectors @@ -302,7 +304,7 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu edm::Handle pc; - if(computeMiniIso_) + if(computeMiniIso_ || computePuppiCombinedIso_) iEvent.getByToken(pcToken_, pc); // get the ESHandle for the transient track builder, @@ -650,12 +652,24 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu double miniIsoValue = -1; if (computeMiniIso_){ // MiniIsolation working points + miniIsoValue = getRelMiniIsoPUCorrected(muon,*rho); + muon.setSelector(reco::Muon::MiniIsoLoose, miniIsoValue<0.40); muon.setSelector(reco::Muon::MiniIsoMedium, miniIsoValue<0.20); muon.setSelector(reco::Muon::MiniIsoTight, miniIsoValue<0.10); muon.setSelector(reco::Muon::MiniIsoVeryTight, miniIsoValue<0.05); } + + double puppiCombinedIsolationPAT = -1; + if(computePuppiCombinedIso_){ + + puppiCombinedIsolationPAT=puppiCombinedIsolation(muon, pc.product()); + muon.setSelector(reco::Muon::PuppiIsoLoose, puppiCombinedIsolationPAT<0.27); + muon.setSelector(reco::Muon::PuppiIsoMedium, puppiCombinedIsolationPAT<0.22); + muon.setSelector(reco::Muon::PuppiIsoTight, puppiCombinedIsolationPAT<0.12); + } + float jetPtRatio = 0.0; float jetPtRel = 0.0; float mva = 0.0; @@ -681,6 +695,8 @@ void PATMuonProducer::produce(edm::Event & iEvent, const edm::EventSetup & iSetu // multi-isolation if (computeMiniIso_){ + + muon.setSelector(reco::Muon::MultiIsoLoose, miniIsoValue<0.40 && (muon.jetPtRatio() > 0.80 || muon.jetPtRel() > 7.2) ); muon.setSelector(reco::Muon::MultiIsoMedium, miniIsoValue<0.16 && (muon.jetPtRatio() > 0.76 || muon.jetPtRel() > 7.2) ); } @@ -815,6 +831,69 @@ double PATMuonProducer::getRelMiniIsoPUCorrected(const pat::Muon& muon, float rh return pat::muonRelMiniIsoPUCorrected(muon.miniPFIsolation(), muon.p4(), drcut, rho); } + +double PATMuonProducer::puppiCombinedIsolation(const pat::Muon& muon, const pat::PackedCandidateCollection *pc) +{ + double dR_threshold = 0.4; + double dR2_threshold = dR_threshold * dR_threshold; + double mix_fraction = 0.5; + enum particleType{ + CH = 0, + NH = 1, + PH = 2, + OTHER = 100000 + }; + double val_PuppiWithLep = 0.0; + double val_PuppiWithoutLep = 0.0; + + for(const auto & cand : *pc){//pat::pat::PackedCandidate loop start + + const particleType pType = + isChargedHadron( cand.pdgId() ) ? CH : + isNeutralHadron( cand.pdgId() ) ? NH : + isPhoton( cand.pdgId() ) ? PH : OTHER; + if( pType == OTHER ){ + if( cand.pdgId() != 1 && cand.pdgId() != 2 + && abs( cand.pdgId() ) != 11 + && abs( cand.pdgId() ) != 13){ + LogTrace("PATMuonProducer") <<"candidate with PDGID = " << cand.pdgId() << " is not CH/NH/PH/e/mu or 1/2 (and this is removed from isolation calculation)" << std::endl; + } + continue; + } + double d_eta = std::abs( cand.eta() - muon.eta() ); + if( d_eta > dR_threshold ) continue; + + double d_phi = std::abs(reco::deltaPhi(cand.phi(),muon.phi())); + if( d_phi > dR_threshold ) continue ; + + double dR2=reco::deltaR2(cand, muon); + if( dR2 > dR2_threshold ) continue; + if( pType == CH && dR2 < 0.0001*0.0001 ) continue; + if( pType == NH && dR2 < 0.01 *0.01 ) continue; + if( pType == PH && dR2 < 0.01 *0.01 ) continue; + val_PuppiWithLep += cand.pt() * cand.puppiWeight(); + val_PuppiWithoutLep += cand.pt() * cand.puppiWeightNoLep(); + + }//pat::pat::PackedCandidate loop end + + double reliso_Puppi_withLep = val_PuppiWithLep/muon.pt(); + double reliso_Puppi_withoutlep = val_PuppiWithoutLep/muon.pt(); + double reliso_Puppi_combined = mix_fraction * reliso_Puppi_withLep + ( 1.0 - mix_fraction) * reliso_Puppi_withoutlep; + return reliso_Puppi_combined; +} + +bool PATMuonProducer::isNeutralHadron( long pdgid ){ + return std::abs(pdgid) == 130; +} + +bool PATMuonProducer::isChargedHadron( long pdgid ){ + return std::abs(pdgid) == 211; +} + +bool PATMuonProducer::isPhoton( long pdgid ){ + return pdgid==22; +} + // ParameterSet description for module void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) { @@ -857,6 +936,8 @@ void PATMuonProducer::fillDescriptions(edm::ConfigurationDescriptions & descript // mini-iso iDesc.add("computeMiniIso", false)->setComment("whether or not to compute and store electron mini-isolation"); + iDesc.add("computePuppiCombinedIso",false)->setComment("whether or not to compute and store puppi combined isolation"); + iDesc.add("pfCandsForMiniIso", edm::InputTag("packedPFCandidates"))->setComment("collection to use to compute mini-iso"); iDesc.add >("miniIsoParams", std::vector())->setComment("mini-iso parameters to use for muons"); diff --git a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h index 1a2918b225c60..5a0fb40832069 100644 --- a/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATMuonProducer.h @@ -101,6 +101,14 @@ namespace pat { void setMuonMiniIso(pat::Muon& aMuon, const pat::PackedCandidateCollection *pc); double getRelMiniIsoPUCorrected(const pat::Muon& muon, float rho); + double puppiCombinedIsolation(const pat::Muon& muon, const pat::PackedCandidateCollection *pc); + bool isNeutralHadron( long pdgid ); + bool isChargedHadron( long pdgid ); + bool isPhoton( long pdgid ); + + + + // embed various impact parameters with errors // embed high level selection void embedHighLevel( pat::Muon & aMuon, @@ -130,6 +138,7 @@ namespace pat { // for mini-iso calculation edm::EDGetTokenT pcToken_; bool computeMiniIso_; + bool computePuppiCombinedIso_; std::vector miniIsoParams_; double relMiniIsoPUCorrected_; diff --git a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h index 6b7b0cad8ab1d..86b7a90bfd0d9 100644 --- a/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h +++ b/PhysicsTools/PatAlgos/plugins/PATPhotonProducer.h @@ -43,7 +43,6 @@ #include "DataFormats/PatCandidates/interface/UserData.h" #include "PhysicsTools/PatAlgos/interface/PATUserDataHelper.h" -#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" @@ -132,7 +131,6 @@ namespace pat { const CaloTopology * ecalTopology_; const CaloGeometry * ecalGeometry_; - EcalClusterLocal ecl_; bool saveRegressionData_; diff --git a/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.cc b/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.cc index b122b6bcbbe55..08480ab2395c3 100644 --- a/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.cc +++ b/PhysicsTools/PatAlgos/plugins/PATTriggerEventProducer.cc @@ -276,7 +276,8 @@ void PATTriggerEventProducer::produce( Event& iEvent, const EventSetup& iSetup ) LogError( "triggerMatchValid" ) << "pat::TriggerObjectStandAloneMatch product with InputTag '" << labelTriggerObjectMatcher << "' not in event"; continue; } - AssociativeIterator< reco::CandidateBaseRef, TriggerObjectStandAloneMatch > it( *handleTriggerObjectStandAloneMatch, EdmEventItemGetter< reco::CandidateBaseRef >( iEvent ) ), itEnd( it.end() ); + auto it = makeAssociativeIterator< reco::CandidateBaseRef>( *handleTriggerObjectStandAloneMatch, iEvent ); + auto itEnd = it.end(); Handle< reco::CandidateView > handleCands; if ( it != itEnd ) iEvent.get( it->first.id(), handleCands ); std::vector< int > indices; diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py b/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py index cff50fb7c31a6..7fa0add40d8f2 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/muonProducer_cfi.py @@ -102,6 +102,7 @@ pfCandsForMiniIso = cms.InputTag("packedPFCandidates"), miniIsoParams = cms.vdouble(0.05, 0.2, 10.0, 0.5, 0.0001, 0.01, 0.01, 0.01, 0.0), + computePuppiCombinedIso = cms.bool(False), # Standard Muon Selectors and Jet-related observables # Depends on MiniIsolation, so only works in miniaod # Don't forget to set flags properly in miniAOD_tools.py diff --git a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py index 84d755f7f5322..2041663047cb1 100644 --- a/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/MicroEventContent_cff.py @@ -78,6 +78,7 @@ 'keep LumiScalerss_scalersRawToDigi_*_*', # CTPPS 'keep CTPPSLocalTrackLites_ctppsLocalTrackLiteProducer_*_*', + 'keep recoForwardProtons_ctppsProtons_*_*', # displacedStandAlone muon collection for EXO 'keep recoTracks_displacedStandAloneMuons__*', ) diff --git a/PhysicsTools/PatAlgos/python/slimming/applySubstructure_cff.py b/PhysicsTools/PatAlgos/python/slimming/applySubstructure_cff.py index d1172350fd8f0..f705622e5940a 100644 --- a/PhysicsTools/PatAlgos/python/slimming/applySubstructure_cff.py +++ b/PhysicsTools/PatAlgos/python/slimming/applySubstructure_cff.py @@ -229,7 +229,7 @@ def applySubstructure( process, postfix="" ) : 'userFloat("NjettinessAK8'+postfix+':tau2")', 'userFloat("NjettinessAK8'+postfix+':tau3")', 'userFloat("NjettinessAK8'+postfix+':tau4")', - 'pt','eta','phi','mass' + 'pt','eta','phi','mass', 'jetArea', 'jecFactor(0)' ]), valueLabels = cms.vstring( [ 'ak8PFJetsCHSPrunedMass', @@ -238,7 +238,7 @@ def applySubstructure( process, postfix="" ) : 'NjettinessAK8CHSTau2', 'NjettinessAK8CHSTau3', 'NjettinessAK8CHSTau4', - 'pt','eta','phi','mass' + 'pt','eta','phi','mass', 'jetArea', 'rawFactor' ]) ), process, task) @@ -255,6 +255,8 @@ def applySubstructure( process, postfix="" ) : cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'eta'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'phi'), cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'mass'), + cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'jetArea'), + cms.InputTag('ak8PFJetsCHSValueMap'+postfix,'rawFactor'), ] diff --git a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py index 204a0adcdc255..278bfb306fd5f 100644 --- a/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py +++ b/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py @@ -25,12 +25,13 @@ def miniAOD_customizeCommon(process): process.patMuons.puppiNoLeptonsIsolationNeutralHadrons = cms.InputTag("muonPUPPINoLeptonsIsolation","h0-DR040-ThresholdVeto000-ConeVeto001") process.patMuons.puppiNoLeptonsIsolationPhotons = cms.InputTag("muonPUPPINoLeptonsIsolation","gamma-DR040-ThresholdVeto000-ConeVeto001") - process.patMuons.computeMiniIso = cms.bool(True) - process.patMuons.computeMuonMVA = cms.bool(True) - process.patMuons.computeSoftMuonMVA = cms.bool(True) + process.patMuons.computeMiniIso = True + process.patMuons.computeMuonMVA = True + process.patMuons.computeSoftMuonMVA = True process.patMuons.addTriggerMatching = True + process.patMuons.computePuppiCombinedIso = True # # disable embedding of electron and photon associated objects already stored by the ReducedEGProducer process.patElectrons.embedGsfElectronCore = False ## process.patElectrons.embed in AOD externally stored gsf electron core @@ -512,8 +513,10 @@ def miniAOD_customizeData(process): from PhysicsTools.PatAlgos.tools.coreTools import runOnData runOnData( process, outputModules = [] ) process.load("RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff") + process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") task = getPatAlgosToolsTask(process) task.add(process.ctppsLocalTrackLiteProducer) + task.add(process.ctppsProtons) def miniAOD_customizeAllData(process): miniAOD_customizeCommon(process) diff --git a/PhysicsTools/PatUtils/src/TriggerHelper.cc b/PhysicsTools/PatUtils/src/TriggerHelper.cc index 049f1858e8794..12a540bfe2bb7 100644 --- a/PhysicsTools/PatUtils/src/TriggerHelper.cc +++ b/PhysicsTools/PatUtils/src/TriggerHelper.cc @@ -21,7 +21,8 @@ using namespace pat::helper; TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const { if ( matchResult ) { - edm::AssociativeIterator< reco::CandidateBaseRef, TriggerObjectMatch > it( *matchResult, edm::EdmEventItemGetter< reco::CandidateBaseRef >( event ) ), itEnd( it.end() ); + auto it = edm::makeAssociativeIterator< reco::CandidateBaseRef>( *matchResult, event ); + auto itEnd = it.end() ; while ( it != itEnd ) { if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) { if ( it->first.id() == candRef.id() && it->first.key() == candRef.key() ) { @@ -60,7 +61,8 @@ reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const T { reco::CandidateBaseRefVector theCands; if ( matchResult ) { - edm::AssociativeIterator< reco::CandidateBaseRef, TriggerObjectMatch > it( *matchResult, edm::EdmEventItemGetter< reco::CandidateBaseRef >( event ) ), itEnd( it.end() ); + auto it = edm::makeAssociativeIterator< reco::CandidateBaseRef>( *matchResult, event ); + auto itEnd = it.end() ; while ( it != itEnd ) { if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) { if ( it->second == objectRef ) { diff --git a/PhysicsTools/TagAndProbe/plugins/ElectronConversionRejectionVars.cc b/PhysicsTools/TagAndProbe/plugins/ElectronConversionRejectionVars.cc index e40e453ba4925..f3635bbc2e917 100644 --- a/PhysicsTools/TagAndProbe/plugins/ElectronConversionRejectionVars.cc +++ b/PhysicsTools/TagAndProbe/plugins/ElectronConversionRejectionVars.cc @@ -86,7 +86,6 @@ ElectronConversionRejectionVars::produce(edm::Event & iEvent, const edm::EventSe double dcot = 0.0; double convradius = 0.0; double passConvRej = 0.0; - ConversionFinder convFinder; View::const_iterator probe, endprobes = probes->end(); const reco::GsfElectronCollection* electronCollection = elHandle.product(); @@ -97,10 +96,10 @@ ElectronConversionRejectionVars::produce(edm::Event & iEvent, const edm::EventSe if( fabs(eleIt->et() - probe->et() ) < 0.05 && fabs(eleIt->eta() - probe->eta() ) < 0.01 && fabs(eleIt->phi() - probe->phi() ) < 0.01 ){ //we have a match - ConversionInfo convInfo = convFinder.getConversionInfo(*eleIt, tracks_h, evt_bField); - dist = convInfo.dist(); - dcot = convInfo.dcot(); - convradius = convInfo.radiusOfConversion(); + ConversionInfo convInfo = egammaTools::getConversionInfo(*eleIt, tracks_h, evt_bField); + dist = convInfo.dist; + dcot = convInfo.dcot; + convradius = convInfo.radiusOfConversion; if( fabs(dist)>0.02 && fabs(dcot)>0.02) passConvRej = 1.0; break; //got our guy, so break } diff --git a/PhysicsTools/UtilAlgos/bin/BuildFile.xml b/PhysicsTools/UtilAlgos/bin/BuildFile.xml index c2c4d4dfc3631..7ff57bea378ff 100644 --- a/PhysicsTools/UtilAlgos/bin/BuildFile.xml +++ b/PhysicsTools/UtilAlgos/bin/BuildFile.xml @@ -2,6 +2,7 @@ + diff --git a/PhysicsTools/UtilAlgos/interface/AdHocNTupler.h b/PhysicsTools/UtilAlgos/interface/AdHocNTupler.h index 55561960a2161..b889d9e6f49fb 100644 --- a/PhysicsTools/UtilAlgos/interface/AdHocNTupler.h +++ b/PhysicsTools/UtilAlgos/interface/AdHocNTupler.h @@ -733,8 +733,7 @@ class AdHocNTupler : public NTupler { //if(!el->closestCtfTrackRef().isNonnull()) //cout<< "Could not find an electron ctf track" << endl; - ConversionFinder convFinder; - ConversionInfo convInfo = convFinder.getConversionInfo(*el, tracks_h, evt_bField); + ConversionInfo convInfo = egammaTools::getConversionInfo(*el, tracks_h, evt_bField); (*els_conversion_dist).push_back(convInfo.dist()); (*els_conversion_dcot).push_back(convInfo.dcot()); diff --git a/RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.cc b/RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.cc index 2bb481763fbf4..6ea6aabd01107 100644 --- a/RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.cc +++ b/RecoBTag/PerformanceDB/plugins/BtagPerformanceESProducer.cc @@ -31,11 +31,7 @@ BtagPerformanceESProducer::produce(const BTagPerformanceRecord & iRecord){ ESHandle wp; iRecord.getRecord().get(mypl,pl); - std::cout <<"HERE "<().get(mywp,wp); - std::cout <<"HERE "< + + + + + + + + + + + + + diff --git a/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h new file mode 100644 index 0000000000000..558f8060e91a2 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -0,0 +1,89 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + +#ifndef RecoCTPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h +#define RecoCTPPS_ProtonReconstruction_ProtonReconstructionAlgorithm_h + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + +#include "TSpline.h" +#include "Fit/Fitter.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class ProtonReconstructionAlgorithm +{ + public: + ProtonReconstructionAlgorithm(bool fit_vtx_y, bool improved_estimate, unsigned int verbosity); + ~ProtonReconstructionAlgorithm() = default; + + void init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions); + void release(); + + /// run proton reconstruction using single-RP strategy + void reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& input, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const; + + /// run proton reconstruction using multiple-RP strategy + void reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& input, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const; + + private: + unsigned int verbosity_; + bool fitVtxY_; + bool useImprovedInitialEstimate_; + bool initialized_; + + /// optics data associated with 1 RP + struct RPOpticsData + { + const LHCInterpolatedOpticalFunctionsSet *optics; + std::shared_ptr s_xi_vs_x_d, s_y_d_vs_xi, s_v_y_vs_xi, s_L_y_vs_xi; + double x0; ///< beam horizontal position, cm + double y0; ///< beam vertical position, cm + double ch0; ///< intercept for linear approximation of \f$x(\xi)\f$ + double ch1; ///< slope for linear approximation of \f$x(\xi)\f$ + double la0; ///< intercept for linear approximation of \f$L_x(\xi)\f$ + double la1; ///< slope for linear approximation of \f$L_x(\xi)\f$ + }; + + /// map: RP id --> optics data + std::map m_rp_optics_; + + /// class for calculation of chi^2 + class ChiSquareCalculator + { + public: + ChiSquareCalculator() = default; + + double operator() (const double *parameters) const; + + const CTPPSLocalTrackLiteRefVector* tracks; + const std::map* m_rp_optics; + }; + + /// fitter object + std::unique_ptr fitter_; + + /// object to calculate chi^2 + std::unique_ptr chiSquareCalculator_; + + static void doLinearFit(const std::vector &vx, const std::vector &vy, double &b, double &a); +}; + +#endif + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml b/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml new file mode 100644 index 0000000000000..2573f06b47d48 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/plugins/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc new file mode 100644 index 0000000000000..d53e20e6a613e --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -0,0 +1,225 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESWatcher.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" + +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" + +#include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonProducer : public edm::stream::EDProducer<> +{ + public: + explicit CTPPSProtonProducer(const edm::ParameterSet&); + ~CTPPSProtonProducer() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + void produce(edm::Event&, const edm::EventSetup&) override; + + edm::EDGetTokenT tracksToken_; + + std::string lhcInfoLabel_; + + unsigned int verbosity_; + + bool doSingleRPReconstruction_; + bool doMultiRPReconstruction_; + + std::string singleRPReconstructionLabel_; + std::string multiRPReconstructionLabel_; + + ProtonReconstructionAlgorithm algorithm_; + + bool opticsValid_; + float currentCrossingAngle_; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet& iConfig) : + tracksToken_ (consumes(iConfig.getParameter("tagLocalTrackLite"))), + lhcInfoLabel_ (iConfig.getParameter("lhcInfoLabel")), + verbosity_ (iConfig.getUntrackedParameter("verbosity", 0)), + doSingleRPReconstruction_ (iConfig.getParameter("doSingleRPReconstruction")), + doMultiRPReconstruction_ (iConfig.getParameter("doMultiRPReconstruction")), + singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), + multiRPReconstructionLabel_ (iConfig.getParameter("multiRPReconstructionLabel")), + algorithm_ (iConfig.getParameter("fitVtxY"), iConfig.getParameter("useImprovedInitialEstimate"), verbosity_), + opticsValid_(false), + currentCrossingAngle_(-1.) +{ + if (doSingleRPReconstruction_) + produces(singleRPReconstructionLabel_); + + if (doMultiRPReconstruction_) + produces(multiRPReconstructionLabel_); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + + desc.add("tagLocalTrackLite", edm::InputTag("ctppsLocalTrackLiteProducer")) + ->setComment("specification of the input lite-track collection"); + + desc.add("lhcInfoLabel", "") + ->setComment("label of the LHCInfo record"); + + desc.addUntracked("verbosity", 0)->setComment("verbosity level"); + + desc.add("doSingleRPReconstruction", true) + ->setComment("flag whether to apply single-RP reconstruction strategy"); + + desc.add("doMultiRPReconstruction", true) + ->setComment("flag whether to apply multi-RP reconstruction strategy"); + + desc.add("singleRPReconstructionLabel", "singleRP") + ->setComment("output label for single-RP reconstruction products"); + + desc.add("multiRPReconstructionLabel", "multiRP") + ->setComment("output label for multi-RP reconstruction products"); + + desc.add("fitVtxY", true) + ->setComment("for multi-RP reconstruction, flag whether y* should be free fit parameter"); + + desc.add("useImprovedInitialEstimate", true) + ->setComment("for multi-RP reconstruction, flag whether a quadratic estimate of the initial point should be used"); + + descriptions.add("ctppsProtons", desc); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(lhcInfoLabel_, hLHCInfo); + + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); + + // re-initialise algorithm upon crossing-angle change + if (hLHCInfo->crossingAngle() != currentCrossingAngle_) { + currentCrossingAngle_ = hLHCInfo->crossingAngle(); + + if (hOpticalFunctions->empty()) { + edm::LogInfo("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; + algorithm_.release(); + opticsValid_ = false; + } + else { + algorithm_.init(*hOpticalFunctions); + opticsValid_ = true; + } + } + + // book output + std::unique_ptr pOutSingleRP(new reco::ForwardProtonCollection); + std::unique_ptr pOutMultiRP(new reco::ForwardProtonCollection); + + // do reconstruction only if optics is valid + if (opticsValid_) + { + // prepare log + std::ostringstream ssLog; + if (verbosity_) + ssLog << "input tracks:"; + + // get input + edm::Handle hTracks; + iEvent.getByToken(tracksToken_, hTracks); + + // keep only tracks from tracker RPs, split them by LHC sector + CTPPSLocalTrackLiteRefVector tracks_45, tracks_56; + std::map nTracksPerRP; + for (unsigned int idx = 0; idx < hTracks->size(); ++idx) { + const auto& tr = hTracks->at(idx); + const CTPPSDetId rpId(tr.getRPId()); + if (rpId.subdetId() != CTPPSDetId::sdTrackingStrip && rpId.subdetId() != CTPPSDetId::sdTrackingPixel) + continue; + + if (verbosity_) + ssLog << "\n\t" + << tr.getRPId() << " (" << (rpId.arm()*100 + rpId.station()*10 + rpId.rp()) << "): " + << "x=" << tr.getX() << " +- " << tr.getXUnc() << " mm, " + << "y=" << tr.getY() << " +- " << tr.getYUnc() << " mm"; + + CTPPSLocalTrackLiteRef r_track(hTracks, idx); + if (rpId.arm() == 0) + tracks_45.push_back(r_track); + if (rpId.arm() == 1) + tracks_56.push_back(r_track); + + nTracksPerRP[rpId]++; + } + + // for the moment: check whether there is no more than 1 track in each arm + bool singleTrack_45 = true, singleTrack_56 = true; + for (const auto& detid_num : nTracksPerRP) { + if (detid_num.second > 1) { + const CTPPSDetId& rpId = detid_num.first; + if (rpId.arm() == 0) + singleTrack_45 = false; + if (rpId.arm() == 1) + singleTrack_56 = false; + } + } + + // single-RP reconstruction + if (doSingleRPReconstruction_) { + algorithm_.reconstructFromSingleRP(tracks_45, *pOutSingleRP, *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(tracks_56, *pOutSingleRP, *hLHCInfo, ssLog); + } + + // multi-RP reconstruction + if (doMultiRPReconstruction_) { + if (singleTrack_45) + algorithm_.reconstructFromMultiRP(tracks_45, *pOutMultiRP, *hLHCInfo, ssLog); + if (singleTrack_56) + algorithm_.reconstructFromMultiRP(tracks_56, *pOutMultiRP, *hLHCInfo, ssLog); + } + + // dump log + if (verbosity_) + edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); + } + + // save output + if (doSingleRPReconstruction_) + iEvent.put(std::move(pOutSingleRP), singleRPReconstructionLabel_); + + if (doMultiRPReconstruction_) + iEvent.put(std::move(pOutMultiRP), multiRPReconstructionLabel_); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonProducer); + diff --git a/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py new file mode 100644 index 0000000000000..dd1f03a267ca1 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/python/ctppsProtons_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +from RecoCTPPS.ProtonReconstruction.ctppsProtons_cfi import * + +# TODO: remove these lines once conditions data are available in DB +from CalibPPS.ESProducers.ctppsAlignment_cff import * +from CalibPPS.ESProducers.ctppsOpticalFunctions_cff import * +ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel diff --git a/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc new file mode 100644 index 0000000000000..a923bd072e658 --- /dev/null +++ b/RecoCTPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -0,0 +1,357 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + +#include "RecoCTPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" + +#include "TMinuitMinimizer.h" + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +ProtonReconstructionAlgorithm::ProtonReconstructionAlgorithm(bool fit_vtx_y, bool improved_estimate, unsigned int verbosity) : + verbosity_(verbosity), + fitVtxY_(fit_vtx_y), + useImprovedInitialEstimate_(improved_estimate), + initialized_(false), + fitter_(new ROOT::Fit::Fitter), chiSquareCalculator_(new ChiSquareCalculator) +{ + // needed for thread safety + TMinuitMinimizer::UseStaticMinuit(false); + + // initialise fitter + double pStart[] = { 0, 0, 0, 0 }; + fitter_->SetFCN(4, *chiSquareCalculator_, pStart, 0, true); +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions) +{ + // reset cache + release(); + + // build optics data for each object + for (const auto &p : opticalFunctions) + { + const LHCInterpolatedOpticalFunctionsSet &ofs = p.second; + + // make record + RPOpticsData rpod; + rpod.optics = &p.second; + rpod.s_y_d_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::eyd]; + rpod.s_v_y_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::evy]; + rpod.s_L_y_vs_xi = ofs.splines()[LHCOpticalFunctionsSet::eLy]; + + vector xiValues = ofs.getXiValues(); // local copy made since the TSpline constructor needs non-const parameters + vector xDValues = ofs.getFcnValues()[LHCOpticalFunctionsSet::exd]; + rpod.s_xi_vs_x_d = make_shared("", xDValues.data(), xiValues.data(), xiValues.size()); + + // calculate auxiliary data + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; + rpod.optics->transport(k_in, k_out); + rpod.x0 = k_out.x; + rpod.y0 = k_out.y; + + doLinearFit(ofs.getXiValues(), ofs.getFcnValues()[LHCOpticalFunctionsSet::exd], rpod.ch0, rpod.ch1); + rpod.ch0 -= rpod.x0; + + doLinearFit(ofs.getXiValues(), ofs.getFcnValues()[LHCOpticalFunctionsSet::eLx], rpod.la0, rpod.la1); + + // insert record + const CTPPSDetId rpId(p.first); + m_rp_optics_.emplace(rpId, std::move(rpod)); + } + + // update settings + initialized_ = true; +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::doLinearFit(const std::vector &vx, const std::vector &vy, double &b, double &a) +{ + double s_1=0., s_x=0., s_xx=0., s_y=0., s_xy=0.; + for (unsigned int i = 0; i < vx.size(); ++i) + { + s_1 += 1.; + s_x += vx[i]; + s_xx += vx[i] * vx[i]; + s_y += vy[i]; + s_xy += vx[i] * vy[i]; + } + + const double d = s_xx * s_1 - s_x * s_x; + a = ( s_1 * s_xy - s_x * s_y) / d; + b = (-s_x * s_xy + s_xx * s_y) / d; +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::release() +{ + initialized_ = false; + + m_rp_optics_.clear(); +} + +//---------------------------------------------------------------------------------------------------- + +double ProtonReconstructionAlgorithm::ChiSquareCalculator::operator() (const double* parameters) const +{ + // extract proton parameters + const LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { 0., parameters[1], parameters[3], parameters[2], parameters[0] }; + + // calculate chi^2 by looping over hits + double s2 = 0.; + + for (const auto &track : *tracks) { + const CTPPSDetId rpId(track->getRPId()); + + // transport proton to the RP + auto oit = m_rp_optics->find(rpId); + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; + oit->second.optics->transport(k_in, k_out); + + // proton position wrt. beam + const double x = k_out.x - oit->second.x0; + const double y = k_out.y - oit->second.y0; + + // calculate chi^2 contributions, convert track data mm --> cm + const double x_diff_norm = (x - track->getX()*1E-1) / (track->getXUnc()*1E-1); + const double y_diff_norm = (y - track->getY()*1E-1) / (track->getYUnc()*1E-1); + + // increase chi^2 + s2 += x_diff_norm*x_diff_norm + y_diff_norm*y_diff_norm; + } + + return s2; +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector& tracks, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const +{ + if (!initialized_) + return; + + // need at least two tracks + if (tracks.size() < 2) + return; + + // make sure optics is available for all tracks + for (const auto &it : tracks) { + auto oit = m_rp_optics_.find(it->getRPId()); + if (oit == m_rp_optics_.end()) + throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << + it->getRPId() << ", i.e. " << CTPPSDetId(it->getRPId()) << "."; + } + + // initial estimate of xi and th_x + double xi_init = 0., th_x_init = 0.; + + if (useImprovedInitialEstimate_) { + double x_N = tracks[0]->getX()*1E-1, // conversion: mm --> cm + x_F = tracks[1]->getX()*1E-1; + + const RPOpticsData &i_N = m_rp_optics_.find(tracks[0]->getRPId())->second, + &i_F = m_rp_optics_.find(tracks[1]->getRPId())->second; + + const double a = i_F.ch1*i_N.la1 - i_N.ch1*i_F.la1; + const double b = i_F.ch0*i_N.la1 - i_N.ch0*i_F.la1 + i_F.ch1*i_N.la0 - i_N.ch1*i_F.la0 + x_N*i_F.la1 - x_F*i_N.la1; + const double c = x_N*i_F.la0 - x_F*i_N.la0 + i_F.ch0*i_N.la0 - i_N.ch0*i_F.la0; + const double D = b*b - 4.*a*c; + + xi_init = (-b + sqrt(D)) / 2. / a; + th_x_init = (x_N - i_N.ch0 - i_N.ch1 * xi_init) / (i_N.la0 + i_N.la1 * xi_init); + } + else { + double s_xi0 = 0., s_1 = 0.; + for (const auto &track : tracks) { + auto oit = m_rp_optics_.find(track->getRPId()); + double xi = oit->second.s_xi_vs_x_d->Eval(track->getX()*1E-1 + oit->second.x0); // conversion: mm --> cm + + s_1 += 1.; + s_xi0 += xi; + } + + xi_init = s_xi0 / s_1; + } + + // initial estimate of th_y and vtx_y + double y[2], v_y[2], L_y[2]; + unsigned int y_idx = 0; + for (const auto &track : tracks) { + if (y_idx >= 2) + continue; + + auto oit = m_rp_optics_.find(track->getRPId()); + + y[y_idx] = track->getY()*1E-1 - oit->second.s_y_d_vs_xi->Eval(xi_init); // track y: mm --> cm + v_y[y_idx] = oit->second.s_v_y_vs_xi->Eval(xi_init); + L_y[y_idx] = oit->second.s_L_y_vs_xi->Eval(xi_init); + + y_idx++; + } + + double vtx_y_init = 0.; + double th_y_init = 0.; + + if (fitVtxY_) { + const double det_y = v_y[0] * L_y[1] - L_y[0] * v_y[1]; + vtx_y_init = (L_y[1] * y[0] - L_y[0] * y[1]) / det_y; + th_y_init = (v_y[0] * y[1] - v_y[1] * y[0]) / det_y; + } + else { + vtx_y_init = 0.; + th_y_init = (y[1]/L_y[1] + y[0]/L_y[0]) / 2.; + } + + unsigned int armId = CTPPSDetId((*tracks.begin())->getRPId()).arm(); + + if (verbosity_) + os << "\n" + << "ProtonReconstructionAlgorithm::reconstructFromMultiRP(" << armId << ")" << std::endl + << " initial estimate: xi_init = " << xi_init << ", th_x_init = " << th_x_init + << ", th_y_init = " << th_y_init << ", vtx_y_init = " << vtx_y_init << "."; + + // minimisation + fitter_->Config().ParSettings(0).Set("xi", xi_init, 0.005); + fitter_->Config().ParSettings(1).Set("th_x", th_x_init, 2E-6); + fitter_->Config().ParSettings(2).Set("th_y", th_y_init, 2E-6); + fitter_->Config().ParSettings(3).Set("vtx_y", vtx_y_init, 10E-6); + + if (!fitVtxY_) + fitter_->Config().ParSettings(3).Fix(); + + chiSquareCalculator_->tracks = &tracks; + chiSquareCalculator_->m_rp_optics = &m_rp_optics_; + + fitter_->FitFCN(); + fitter_->FitFCN(); // second minimisation in case the first one had troubles + + // extract proton parameters + const ROOT::Fit::FitResult& result = fitter_->Result(); + const double *params = result.GetParams(); + + if (verbosity_) + os << "\n" + << "xi=" << params[0] << " +- " << result.Error(0) + << ", th_x=" << params[1] << " +-" << result.Error(1) + << ", th_y=" << params[2] << " +-" << result.Error(2) + << ", vtx_y=" << params[3] << " +-" << result.Error(3) + << ", chiSq = " << result.Chi2(); + + // save reco candidate + using FP = reco::ForwardProton; + + const double sign_z = (armId == 0) ? +1. : -1.; // CMS convention + const FP::Point vertex(0., params[3], 0.); + const double xi = params[0]; + const double th_x = params[1]; + const double th_y = params[2]; + const double cos_th = sqrt(1. - th_x*th_x - th_y*th_y); + const double p = lhcInfo.energy() * (1. - xi); + const FP::Vector momentum( + - p * th_x, // the signs reflect change LHC --> CMS convention + + p * th_y, + sign_z * p * cos_th + ); + signed int ndf = 2.*tracks.size() - ((fitVtxY_) ? 4. : 3.); + + map index_map = { + {(unsigned int) FP::Index::xi, 0}, + {(unsigned int) FP::Index::th_x, 1}, + {(unsigned int) FP::Index::th_y, 2}, + {(unsigned int) FP::Index::vtx_y, ((fitVtxY_) ? 3 : -1)}, + {(unsigned int) FP::Index::vtx_x, -1}, + }; + + FP::CovarianceMatrix cm; + for (unsigned int i = 0; i < (unsigned int) FP::Index::num_indices; ++i) { + signed int fit_i = index_map[i]; + + for (unsigned int j = 0; j < (unsigned int) FP::Index::num_indices; ++j) { + signed int fit_j = index_map[j]; + + cm(i, j) = (fit_i >= 0 && fit_j >= 0) ? result.CovMatrix(fit_i, fit_j) : 0.; + } + } + + output.emplace_back(result.Chi2(), ndf, vertex, momentum, xi, cm, FP::ReconstructionMethod::multiRP, tracks, result.IsValid()); +} + +//---------------------------------------------------------------------------------------------------- + +void ProtonReconstructionAlgorithm::reconstructFromSingleRP(const CTPPSLocalTrackLiteRefVector& tracks, + reco::ForwardProtonCollection& output, + const LHCInfo& lhcInfo, std::ostream& os) const +{ + if (!initialized_) + return; + + // make sure optics is available for all tracks + for (const auto &it : tracks) { + auto oit = m_rp_optics_.find(it->getRPId()); + if (oit == m_rp_optics_.end()) + throw cms::Exception("ProtonReconstructionAlgorithm") << "Optics data not available for RP " << it->getRPId() + << ", i.e. " << CTPPSDetId(it->getRPId()) << "."; + } + + // rough estimate of xi and th_y from each track + for (const auto &track : tracks) { + CTPPSDetId rpId(track->getRPId()); + + if (verbosity_) + os << "\nreconstructFromSingleRP(" << rpId.arm()*100 + rpId.station()*10 + rpId.rp() << ")"; + + auto oit = m_rp_optics_.find(track->getRPId()); + const double x_full = track->getX()*1E-1 + oit->second.x0; // conversion mm --> cm + const double xi = oit->second.s_xi_vs_x_d->Eval(x_full); + const double L_y = oit->second.s_L_y_vs_xi->Eval(xi); + const double th_y = track->getY()*1E-1 / L_y; // conversion mm --> cm + + const double ep_x = 1E-6; + const double dxi_dx = (oit->second.s_xi_vs_x_d->Eval(x_full + ep_x) - xi) / ep_x; + const double xi_unc = abs(dxi_dx) * track->getXUnc() * 1E-1; // conversion mm --> cm + + const double ep_xi = 1E-4; + const double dL_y_dxi = ( oit->second.s_L_y_vs_xi->Eval(xi + ep_xi) - L_y ) / ep_xi; + const double th_y_unc = th_y * sqrt( pow(track->getYUnc() / track->getY(), 2.) + pow(dL_y_dxi * xi_unc / L_y, 2.) ); + + if (verbosity_) + os << "\n xi = " << xi << " +- " << xi_unc << ", th_y = " << th_y << " +- " << th_y_unc << "."; + + using FP = reco::ForwardProton; + + // save proton candidate + + const double sign_z = (CTPPSDetId(track->getRPId()).arm() == 0) ? +1. : -1.; // CMS convention + const FP::Point vertex(0., 0., 0.); + const double cos_th = sqrt(1. - th_y*th_y); + const double p = lhcInfo.energy() * (1. - xi); + const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); + + FP::CovarianceMatrix cm; + cm((int)FP::Index::xi, (int)FP::Index::xi) = xi_unc * xi_unc; + cm((int)FP::Index::th_y, (int)FP::Index::th_y) = th_y_unc * th_y_unc; + + CTPPSLocalTrackLiteRefVector trk; + trk.push_back( track ); + output.emplace_back(0., 0, vertex, momentum, xi, cm, FP::ReconstructionMethod::singleRP, trk, true); + } +} + diff --git a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc index dcca2caef325d..20a0db477695d 100644 --- a/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc +++ b/RecoCTPPS/TotemRPLocal/plugins/CTPPSLocalTrackLiteProducer.cc @@ -204,23 +204,27 @@ CTPPSLocalTrackLiteProducer::fillDescriptions( edm::ConfigurationDescriptions& d { edm::ParameterSetDescription desc; - desc.add("includeStrips", true)->setComment("whether tracks from Si strips should be included"); + // By default: module enabled (doNothing=false), but all includeXYZ flags set to false. + // The includeXYZ are switched on when the "ctpps_2016" era is declared in python config, see: + // RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py + + desc.add("includeStrips", false)->setComment("whether tracks from Si strips should be included"); desc.add( "tagSiStripTrack", edm::InputTag( "totemRPLocalTrackFitter" ) ) ->setComment( "input TOTEM strips' local tracks collection to retrieve" ); - desc.add("includeDiamonds", true)->setComment("whether tracks from diamonds strips should be included"); + desc.add("includeDiamonds", false)->setComment("whether tracks from diamonds strips should be included"); desc.add( "tagDiamondTrack", edm::InputTag( "ctppsDiamondLocalTracks" ) ) ->setComment( "input diamond detectors' local tracks collection to retrieve" ); - desc.add("includePixels", true)->setComment("whether tracks from pixels should be included"); - desc.add( "tagPixelTrack" , edm::InputTag( "ctppsPixelLocalTracks" ) ) + desc.add("includePixels", false)->setComment("whether tracks from pixels should be included"); + desc.add( "tagPixelTrack", edm::InputTag( "ctppsPixelLocalTracks" ) ) ->setComment( "input pixel detectors' local tracks collection to retrieve" ); - desc.add( "doNothing", true ) // disable the module by default + desc.add( "doNothing", false ) // enable the module by default ->setComment( "disable the module" ); desc.add( "timingTrackTMin", -1000. ) - ->setComment( "minimal track time selection for timing detectors [ns]" ); + ->setComment( "minimal track time selection for timing detectors" ); desc.add( "timingTrackTMax", +1000. ) - ->setComment( "maximal track time selection for timing detectors [ns]" ); + ->setComment( "maximal track time selection for timing detectors" ); desc.add("pixelTrackTxMin",-10.0); desc.add("pixelTrackTxMax", 10.0); diff --git a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py index ace76c2c803dc..892ef77aae739 100644 --- a/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py +++ b/RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py @@ -8,7 +8,9 @@ from Configuration.Eras.Modifier_ctpps_2016_cff import ctpps_2016 ctpps_2016.toModify( ctppsLocalTrackLiteProducer, - doNothing = cms.bool(False) + includeStrips = True, + includeDiamonds = True, + includePixels = True ) from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy diff --git a/RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h b/RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h index 3c7b8720a8b11..70f509072dda3 100644 --- a/RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h +++ b/RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h @@ -1,26 +1,11 @@ #ifndef RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H #define RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H -#include -#include -#include -#include -#include - - -//=============================================================== -// Normalization of angles -//=============================================================== - -template -RealType normalized_phi( RealType phi ) - { - constexpr RealType pi(M_PI); - constexpr RealType pi2(2*M_PI); - if (phi>pi) { phi -= pi2 ; } - if (phi<-pi) { phi += pi2; } - return phi ; - } +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/GeometryVector/interface/GlobalVector.h" +#include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/Math/interface/Vector3D.h" +#include "DataFormats/Math/interface/normalizedPhi.h" //=============================================================== @@ -46,7 +31,7 @@ class EleRelPoint EleRelPoint( const math::XYZPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {} EleRelPoint( const GlobalPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {} double eta() { return relP_.eta() ; } - double phi() { return normalized_phi(relP_.phi()) ; } + double phi() { return normalizedPhi(relP_.phi()) ; } double perp() { return std::sqrt(relP_.x()*relP_.x()+relP_.y()*relP_.y()) ; } private : math::XYZVector relP_ ; @@ -64,7 +49,7 @@ class EleRelPointPair EleRelPointPair( const GlobalPoint & p1, const math::XYZPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {} EleRelPointPair( const GlobalPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {} auto dEta() { return (relP1_.eta()-relP2_.eta()) ; } - auto dPhi() { return normalized_phi(relP1_.barePhi()-relP2_.barePhi()) ; } + auto dPhi() { return normalizedPhi(relP1_.barePhi()-relP2_.barePhi()) ; } auto dZ() { return (relP1_.z()-relP2_.z()) ; } auto dPerp() { return (relP1_.perp()-relP2_.perp()) ; } private : @@ -86,8 +71,7 @@ double relative_eta( const PointType & p, const PointType & origin ) template double relative_phi( const PointType & p, const PointType & origin ) - { return normalized_phi((p-origin).phi()) ; } + { return normalizedPhi((p-origin).phi()) ; } #endif - diff --git a/RecoEgamma/EgammaElectronAlgos/interface/RegressionHelper.h b/RecoEgamma/EgammaElectronAlgos/interface/RegressionHelper.h index 83ec6c21fc78f..15b3d47c62114 100644 --- a/RecoEgamma/EgammaElectronAlgos/interface/RegressionHelper.h +++ b/RecoEgamma/EgammaElectronAlgos/interface/RegressionHelper.h @@ -20,11 +20,6 @@ #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" - - - -class EcalClusterLocal; class RegressionHelper { public: @@ -77,7 +72,6 @@ class RegressionHelper { const GBRForest * ecalRegErrorEndcap_ ; const GBRForest * combinationReg_ ; - EcalClusterLocal ecl_; }; #endif diff --git a/RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc b/RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc index 433e22db21c44..96f44eb15d64c 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/BarrelMeasurementEstimator.cc @@ -21,6 +21,7 @@ #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h" #include "TrackingTools/DetLayers/interface/rangesIntersect.h" #include "DataFormats/GeometryVector/interface/VectorUtil.h" +#include "DataFormats/Math/interface/normalizedPhi.h" // zero value indicates incompatible ts - hit pair @@ -53,9 +54,7 @@ std::pair BarrelMeasurementEstimator::estimate( const TrajectorySta float rhPhi = gp.phi(); - float phiDiff = tsPhi - rhPhi; - if (phiDiff > pi) phiDiff -= twopi; - if (phiDiff < -pi) phiDiff += twopi; + float phiDiff = normalizedPhi(tsPhi - rhPhi); if ( phiDiff < thePhiMax && phiDiff > thePhiMin ) { @@ -91,7 +90,7 @@ std::pair BarrelMeasurementEstimator::estimate float rhPhi = gp.barePhi() ; float tsPhi = ts.barePhi(); - float phiDiff = normalized_phi(rhPhi-tsPhi) ; + float phiDiff = normalizedPhi(rhPhi-tsPhi) ; if ( (phiDiff < thePhiMax) & (phiDiff > thePhiMin) ) { return std::pair(true,1.) ; } diff --git a/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc b/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc index 5cf205eb2f2a1..5b005cb5975cb 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/EnergyUncertaintyElectronSpecific.cc @@ -27,136 +27,123 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde double et = energy/cosh(eta); - const int nBinsEta=5; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.4, 0.8, 1.5, 2.0, 2.5}; - - const int nBinsBrem=6; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.0, 1.1, 1.2, 1.3, 1.5, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - - par0[0][0]=0.00567891; - par1[0][0]=0.238685; - par2[0][0]=2.12035; - - par0[0][1]=0.0065673; - par1[0][1]=0.193642; - par2[0][1]=3.41493; - - par0[0][2]=0.00574742; - par1[0][2]=0.249171; - par2[0][2]=1.7401; - - par0[0][3]=0.00542964; - par1[0][3]=0.259997; - par2[0][3]=1.46234; - - par0[0][4]=0.00523293; - par1[0][4]=0.310505; - par2[0][4]=0.233226; - - par0[0][5]=0.00547518; - par1[0][5]=0.390506; - par2[0][5]=-2.78168; - - par0[1][0]=0.00552517; - par1[1][0]=0.288736; - par2[1][0]=1.30552; - - par0[1][1]=0.00611188; - par1[1][1]=0.312303; - par2[1][1]=0.137905; - - par0[1][2]=0.0062729; - par1[1][2]=0.294717; - par2[1][2]=0.653793; - - par0[1][3]=0.00574846; - par1[1][3]=0.294491; - par2[1][3]=0.790746; - - par0[1][4]=0.00447373; - par1[1][4]=0.379178; - par2[1][4]=-1.42584; - - par0[1][5]=0.00595789; - par1[1][5]=0.38164; - par2[1][5]=-2.34653; - - par0[2][0]=0.00356679; - par1[2][0]=0.456456; - par2[2][0]=0.610716; - - par0[2][1]=0.00503827; - par1[2][1]=0.394912; - par2[2][1]=0.778879; - - par0[2][2]=0.00328016; - par1[2][2]=0.541713; - par2[2][2]=-1.58577; - - par0[2][3]=0.00592303; - par1[2][3]=0.401744; - par2[2][3]=1.45098; - - par0[2][4]=0.00512479; - par1[2][4]=0.483151; - par2[2][4]=-0.0985911; - - par0[2][5]=0.00484166; - par1[2][5]=0.657995; - par2[2][5]=-3.47167; - - par0[3][0]=0.0109195; - par1[3][0]=1.13803; - par2[3][0]=-3.48281; - - par0[3][1]=0.0102361; - par1[3][1]=1.39866; - par2[3][1]=-6.4736; - - par0[3][2]=0.0101576; - par1[3][2]=1.51353; - par2[3][2]=-8.03308; - - par0[3][3]=0.0120683; - par1[3][3]=1.48587; - par2[3][3]=-7.55974; - - par0[3][4]=0.0155326; - par1[3][4]=1.49732; - par2[3][4]=-7.98843; - - par0[3][5]=0.0225035; - par1[3][5]=1.82363; - par2[3][5]=-10.1027; - - par0[4][0]=0.0109632; - par1[4][0]=0.458212; - par2[4][0]=0.995183; - - par0[4][1]=0.0103342; - par1[4][1]=0.628761; - par2[4][1]=-2.42889; - - par0[4][2]=0.0103486; - par1[4][2]=0.659144; - par2[4][2]=-2.14073; - - par0[4][3]=0.00862762; - par1[4][3]=0.929563; - par2[4][3]=-6.27768; - - par0[4][4]=0.0111448; - par1[4][4]=1.06724; - par2[4][4]=-7.68512; - - par0[4][5]=0.0146648; - par1[4][5]=1.6427; - par2[4][5]=-13.3504; - + constexpr int nBinsEta=5; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.4, 0.8, 1.5, 2.0, 2.5}; + + constexpr int nBinsBrem=6; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.0, 1.1, 1.2, 1.3, 1.5, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem] = { + {0.00567891, + 0.0065673, + 0.00574742, + 0.00542964, + 0.00523293, + 0.00547518}, + + {0.00552517, + 0.00611188, + 0.0062729, + 0.00574846, + 0.00447373, + 0.00595789}, + + {0.00356679, + 0.00503827, + 0.00328016, + 0.00592303, + 0.00512479, + 0.00484166}, + + {0.0109195, + 0.0102361, + 0.0101576, + 0.0120683, + 0.0155326, + 0.0225035}, + + {0.0109632, + 0.0103342, + 0.0103486, + 0.00862762, + 0.0111448, + 0.0146648}}; + + static_assert(par0[0][0] == 0.00567891f); + static_assert(par0[0][1] == 0.0065673f); + static_assert(par0[1][3] == 0.00574846f); + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.238685, + 0.193642, + 0.249171, + 0.259997, + 0.310505, + 0.390506}, + + {0.288736, + 0.312303, + 0.294717, + 0.294491, + 0.379178, + 0.38164}, + + {0.456456, + 0.394912, + 0.541713, + 0.401744, + 0.483151, + 0.657995}, + + {1.13803, + 1.39866, + 1.51353, + 1.48587, + 1.49732, + 1.82363}, + + {0.458212, + 0.628761, + 0.659144, + 0.929563, + 1.06724, + 1.6427}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {2.12035, + 3.41493, + 1.7401, + 1.46234, + 0.233226, + -2.78168}, + + {1.30552, + 0.137905, + 0.653793, + 0.790746, + -1.42584, + -2.34653}, + + {0.610716, + 0.778879, + -1.58577, + 1.45098, + -0.0985911, + -3.47167}, + { + -3.48281, + -6.4736, + -8.03308, + -7.55974, + -7.98843, + -10.1027}, + + {0.995183, + -2.42889, + -2.14073, + -6.27768, + -7.68512, + -13.3504}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -176,6 +163,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]); @@ -188,38 +185,35 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_golde double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbrem(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.5, 2.0, 2.5}; + const double et = energy/cosh(eta); - const int nBinsBrem=1; - const Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.5, 2.0, 2.5}; - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; + constexpr int nBinsBrem=1; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; - par0[0][0]=0.00593389; - par1[0][0]=0.178275; - par2[0][0]=-7.28273; - par3[0][0]=13.2632; + constexpr float par0[nBinsEta][nBinsBrem] = + {{0.00593389}, {0.00266954}, + {0.00500623}, {0.00841038} }; - par0[1][0]=0.00266954; - par1[1][0]=0.811415; - par2[1][0]=-1.66063; - par3[1][0]=1.03555; + constexpr float par1[nBinsEta][nBinsBrem] = + {{0.178275}, + {0.811415}, + {2.34018}, + {1.06851}}; - par0[2][0]=0.00500623; - par1[2][0]=2.34018; - par2[2][0]=-11.0129; - par3[2][0]=-0.200323; + constexpr float par2[nBinsEta][nBinsBrem] = + {{-7.28273}, + {-1.66063}, + {-11.0129}, + {-4.1259}}; - par0[3][0]=0.00841038; - par1[3][0]=1.06851; - par2[3][0]=-4.1259; - par3[3][0]=-0.0646195; + constexpr float par3[nBinsEta][nBinsBrem] = + {{13.2632}, + {1.03555}, + {-0.200323}, + {-0.0646195}}; Int_t iEtaSl = -1; @@ -240,6 +234,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbr if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -251,39 +255,37 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_bigbr } double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtrack(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.7, 1.3, 1.8, 2.5}; + const double et = energy/cosh(eta); - const int nBinsBrem=1; - const Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.7, 1.3, 1.8, 2.5}; - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; + constexpr int nBinsBrem=1; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 8.0}; - par0[0][0]=0.00601311; - par1[0][0]=0.390988; - par2[0][0]=-4.11919; - par3[0][0]=4.61671; + constexpr float par0[nBinsEta][nBinsBrem] = + {{0.00601311}, + {0.0059814}, + {0.00953032}, + {0.00728618}}; - par0[1][0]=0.0059814; - par1[1][0]=1.02668; - par2[1][0]=-2.87477; - par3[1][0]=0.163447; + constexpr float par1[nBinsEta][nBinsBrem] = + {{ 0.390988}, + {1.02668}, + {2.27491}, + {2.08268}}; - par0[2][0]=0.00953032; - par1[2][0]=2.27491; - par2[2][0]=-7.61675; - par3[2][0]=-0.335786; - - par0[3][0]=0.00728618; - par1[3][0]=2.08268; - par2[3][0]=-8.66756; - par3[3][0]=-1.27831; + constexpr float par2[nBinsEta][nBinsBrem] = + {{-4.11919}, + {-2.87477}, + {-7.61675}, + {-8.66756}}; + constexpr float par3[nBinsEta][nBinsBrem]= + {{4.61671}, + {0.163447}, + {-0.335786}, + {-1.27831}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -303,6 +305,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtr if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -315,119 +327,113 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_badtr double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showering(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=4; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.2, 1.7, 2.5}; - - const int nBinsBrem=5; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.8, 2.2, 3.0, 4.0, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - float par3[nBinsEta][nBinsBrem]; - - par0[0][0]=0.0049351; - par1[0][0]=0.579925; - par2[0][0]=-9.33987; - par3[0][0]=1.62129; - - par0[0][1]=0.00566155; - par1[0][1]=0.496137; - par2[0][1]=-5.52543; - par3[0][1]=1.19101; - - par0[0][2]=0.0051397; - par1[0][2]=0.551947; - par2[0][2]=-7.30079; - par3[0][2]=1.89701; - - par0[0][3]=0.00468481; - par1[0][3]=0.63011; - par2[0][3]=-6.7722; - par3[0][3]=1.81614; - - par0[0][4]=0.00444475; - par1[0][4]=0.684261; - par2[0][4]=-4.67614; - par3[0][4]=1.64415; - - par0[1][0]=0.00201762; - par1[1][0]=0.914762; - par2[1][0]=-4.48042; - par3[1][0]=-1.50473; - - par0[1][1]=0.00431475; - par1[1][1]=0.824483; - par2[1][1]=-5.02885; - par3[1][1]=-0.153502; - - par0[1][2]=0.00501004; - par1[1][2]=0.888521; - par2[1][2]=-4.77311; - par3[1][2]=-0.355145; - - par0[1][3]=0.00632666; - par1[1][3]=0.960241; - par2[1][3]=-3.36742; - par3[1][3]=-1.16499; - - par0[1][4]=0.00636704; - par1[1][4]=1.25728; - par2[1][4]=-5.53561; - par3[1][4]=-0.864123; - - par0[2][0]=-0.00729396; - par1[2][0]=3.24295; - par2[2][0]=-17.1458; - par3[2][0]=-4.69711; - - par0[2][1]=0.00539783; - par1[2][1]=1.72935; - par2[2][1]=-5.92807; - par3[2][1]=-2.18733; - - par0[2][2]=0.00608149; - par1[2][2]=1.80606; - par2[2][2]=-6.67563; - par3[2][2]=-0.922401; - - par0[2][3]=0.00465335; - par1[2][3]=2.13562; - par2[2][3]=-10.1105; - par3[2][3]=-0.230781; - - par0[2][4]=0.00642685; - par1[2][4]=2.07592; - par2[2][4]=-7.50257; - par3[2][4]=-2.91515; - - par0[3][0]=0.0149449; - par1[3][0]=1.00448; - par2[3][0]=-2.09368; - par3[3][0]=0.455037; - - par0[3][1]=0.0216691; - par1[3][1]=1.18393; - par2[3][1]=-4.56674; - par3[3][1]=-0.601872; - - par0[3][2]=0.0255957; - par1[3][2]=0.00775295; - par2[3][2]=-44.2722; - par3[3][2]=241.516; - - par0[3][3]=0.0206101; - par1[3][3]=2.59246; - par2[3][3]=-13.1702; - par3[3][3]=-2.35024; - - par0[3][4]=0.0180508; - par1[3][4]=3.1099; - par2[3][4]=-13.6208; - par3[3][4]=-2.11069; - + const double et = energy/cosh(eta); + + constexpr int nBinsEta=4; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.8, 1.2, 1.7, 2.5}; + + constexpr int nBinsBrem=5; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.8, 2.2, 3.0, 4.0, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem]= { + {0.0049351, + 0.00566155, + 0.0051397, + 0.00468481, + 0.00444475}, + + {0.00201762, + 0.00431475, + 0.00501004, + 0.00632666, + 0.00636704}, + + {-0.00729396, + 0.00539783, + 0.00608149, + 0.00465335, + 0.00642685}, + + {0.0149449, + 0.0216691, + 0.0255957, + 0.0206101, + 0.0180508} }; + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.579925, + 0.496137, + 0.551947, + 0.63011, + 0.684261}, + + {0.914762, + 0.824483, + 0.888521, + 0.960241, + 1.25728}, + + {3.24295, + 1.72935, + 1.80606, + 2.13562, + 2.07592}, + + {1.00448, + 1.18393, + 0.00775295, + 2.59246, + 3.1099}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {-9.33987, + -5.52543, + -7.30079, + -6.7722, + -4.67614}, + + {-4.48042, + -5.02885, + -4.77311, + -3.36742, + -5.53561}, + + {-17.1458, + -5.92807, + -6.67563, + -10.1105, + -7.50257}, + + {-2.09368, + -4.56674, + -44.2722, + -13.1702, + -13.6208}}; + + constexpr float par3[nBinsEta][nBinsBrem] = { + {1.62129, + 1.19101, + 1.89701, + 1.81614, + 1.64415}, + + {-1.50473, + -0.153502, + -0.355145, + -1.16499, + -0.864123}, + + {-4.69711, + -2.18733, + -0.922401, + -0.230781, + -2.91515}, + + {0.455037, + -0.601872, + 241.516, + -2.35024, + -2.11069}}; Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -447,6 +453,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showe if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]) + par3[iEtaSl][iBremSl]/((100-par2[iEtaSl][iBremSl])*(100-par2[iEtaSl][iBremSl])); @@ -459,138 +475,135 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_showe double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_cracks(double eta, double brem, double energy){ - double et = energy/cosh(eta); - - const int nBinsEta=5; - const Double_t EtaBins[nBinsEta+1] = {0.0, 0.42, 0.78, 1.2, 1.52, 1.65}; - - const int nBinsBrem=6; - const Double_t BremBins[nBinsBrem+1]= {0.8, 1.2, 1.5, 2.1, 3., 4, 8.0}; - - float par0[nBinsEta][nBinsBrem]; - float par1[nBinsEta][nBinsBrem]; - float par2[nBinsEta][nBinsBrem]; - - par0[0][0]=0.0139815; - par1[0][0]=0.569273; - par2[0][0]=-4.31243; - - par0[0][1]=0.00550839; - par1[0][1]=0.674654; - par2[0][1]=-3.071; - - par0[0][2]=0.0108292; - par1[0][2]=0.523128; - par2[0][2]=-2.56702; - - par0[0][3]=0.00596201; - par1[0][3]=1.02501; - par2[0][3]=-7.74555; - - par0[0][4]=-0.00498136; - par1[0][4]=1.75645; - par2[0][4]=-21.3726; - - par0[0][5]=0.000621696; - par1[0][5]=0.955191; - par2[0][5]=-6.2189; - - par0[1][0]=0.00467498; - par1[1][0]=0.697951; - par2[1][0]=-6.56009; - - par0[1][1]=0.00808463; - par1[1][1]=0.580628; - par2[1][1]=-3.66067; - - par0[1][2]=0.00546665; - par1[1][2]=0.814515; - par2[1][2]=-7.8275; - - par0[1][3]=0.00506318; - par1[1][3]=0.819975; - par2[1][3]=-6.01641; - - par0[1][4]=0.00608425; - par1[1][4]=0.829616; - par2[1][4]=-7.85456; - - par0[1][5]=-4.45641e-06; - par1[1][5]=1.18952; - par2[1][5]=-8.27071; - - par0[2][0]=0.00971734; - par1[2][0]=3.79446; - par2[2][0]=-49.9996; - - par0[2][1]=0.00063951; - par1[2][1]=2.47472; - par2[2][1]=-25.0724; - - par0[2][2]=-0.0121618; - par1[2][2]=5.12931; - par2[2][2]=-49.985; - - par0[2][3]=-0.00604365; - par1[2][3]=3.42497; - par2[2][3]=-28.1932; - - par0[2][4]=0.00492161; - par1[2][4]=1.84123; - par2[2][4]=-10.6485; - - par0[2][5]=-0.00143907; - par1[2][5]=2.3773; - par2[2][5]=-15.4014; - - par0[3][0]=-0.0844907; - par1[3][0]=19.9999; - par2[3][0]=-39.9444; - - par0[3][1]=-0.0592498; - par1[3][1]=10.4079; - par2[3][1]=-25.1133; - - par0[3][2]=-0.0828631; - par1[3][2]=16.6273; - par2[3][2]=-49.9999; - - par0[3][3]=-0.0740798; - par1[3][3]=15.9316; - par2[3][3]=-50; - - par0[3][4]=-0.0698045; - par1[3][4]=15.4883; - par2[3][4]=-49.9998; - - par0[3][5]=-0.0699518; - par1[3][5]=14.7306; - par2[3][5]=-49.9998; - - par0[4][0]=-0.0999971; - par1[4][0]=15.9122; - par2[4][0]=-30.1268; - - par0[4][1]=-0.0999996; - par1[4][1]=18.5882; - par2[4][1]=-42.6113; - - par0[4][2]=-0.0989356; - par1[4][2]=19.9996; - par2[4][2]=-46.6999; - - par0[4][3]=-0.0999965; - par1[4][3]=19.9999; - par2[4][3]=-47.074; - - par0[4][4]=-0.0833049; - par1[4][4]=18.2281; - par2[4][4]=-49.9995; - - par0[4][5]=-0.020072; - par1[4][5]=8.1587; - par2[4][5]=-25.2897; - + const double et = energy/cosh(eta); + + constexpr int nBinsEta=5; + constexpr Double_t EtaBins[nBinsEta+1] = {0.0, 0.42, 0.78, 1.2, 1.52, 1.65}; + + constexpr int nBinsBrem=6; + constexpr Double_t BremBins[nBinsBrem+1]= {0.8, 1.2, 1.5, 2.1, 3., 4, 8.0}; + + constexpr float par0[nBinsEta][nBinsBrem] = { + {0.0139815, + 0.00550839, + 0.0108292, + 0.00596201, + -0.00498136, + 0.000621696}, + + {0.00467498, + 0.00808463, + 0.00546665, + 0.00506318, + 0.00608425, + -4.45641e-06}, + + {0.00971734, + 0.00063951, + -0.0121618, + -0.00604365, + 0.00492161, + -0.00143907}, + + {-0.0844907, + -0.0592498, + -0.0828631, + -0.0740798, + -0.0698045, + -0.0699518}, + + {-0.0999971, + -0.0999996, + -0.0989356, + -0.0999965, + -0.0833049, + -0.020072}}; + + constexpr float par1[nBinsEta][nBinsBrem] = { + {0.569273, + 0.674654, + 0.523128, + 1.02501, + 1.75645, + 0.955191}, + + {0.697951, + 0.580628, + 0.814515, + 0.819975, + 0.829616, + 1.18952}, + + {3.79446, + 2.47472, + 5.12931, + 3.42497, + 1.84123, + 2.3773}, + + {19.9999, + 10.4079, + 16.6273, + 15.9316, + 15.4883, + 14.7306}, + + {15.9122, + 18.5882, + 19.9996, + 19.9999, + 18.2281, + 8.1587}}; + + constexpr float par2[nBinsEta][nBinsBrem] = { + {-4.31243, + -3.071, + -2.56702, + -7.74555, + -21.3726, + -6.2189}, + + {-6.56009, + -3.66067, + -7.8275, + -6.01641, + -7.85456, + -8.27071}, + + {-49.9996, + -25.0724, + -49.985, + -28.1932, + -10.6485, + -15.4014}, + + {-39.9444, + -25.1133, + -49.9999, + -50, + -49.9998, + -49.9998}, + + {-30.1268, + -42.6113, + -46.6999, + -47.074, + -49.9995, + -25.2897}}; + + + static_assert(par0[0][3]==0.00596201f); + static_assert(par1[0][3]==1.02501f); + static_assert(par2[0][3]==-7.74555f); + + + static_assert(par0[2][4]==0.00492161f); + static_assert(par1[2][4]==1.84123f); + static_assert(par2[2][4]==-10.6485f); + + static_assert(par0[4][3]==-0.0999965f); + static_assert(par1[4][3]==19.9999f); + static_assert(par2[4][3]==-47.074f); Int_t iEtaSl = -1; for (Int_t iEta = 0; iEta < nBinsEta; ++iEta){ @@ -610,6 +623,16 @@ double EnergyUncertaintyElectronSpecific::computeElectronEnergyUncertainty_crack if (bremBremBins[nBinsBrem-1]) iBremSl = nBinsBrem-1; + if(iEtaSl == -1) { + edm::LogError("BadRange")<<"Bad eta value: "<100) uncertainty = par0[iEtaSl][iBremSl] + par1[iEtaSl][iBremSl]/(100-par2[iEtaSl][iBremSl]); diff --git a/RecoEgamma/EgammaElectronAlgos/src/ForwardMeasurementEstimator.cc b/RecoEgamma/EgammaElectronAlgos/src/ForwardMeasurementEstimator.cc index d92f9aa159b72..72bbc9075c4f5 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/ForwardMeasurementEstimator.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/ForwardMeasurementEstimator.cc @@ -21,6 +21,7 @@ #include "TrackingTools/DetLayers/interface/rangesIntersect.h" #include "DataFormats/GeometryVector/interface/VectorUtil.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" +#include "DataFormats/Math/interface/normalizedPhi.h" // zero value indicates incompatible ts - hit pair std::pair ForwardMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts, @@ -50,9 +51,7 @@ std::pair ForwardMeasurementEstimator::estimate( const TrajectorySt float myPhimin = thePhiMin; float myPhimax = thePhiMax; - float phiDiff = tsPhi - rhPhi; - if (phiDiff > pi) phiDiff -= twopi; - if (phiDiff < -pi) phiDiff += twopi; + float phiDiff = normalizedPhi(tsPhi - rhPhi); if ( (phiDiff < myPhimax) & (phiDiff > myPhimin) ) { return std::pair(true,1.); @@ -88,7 +87,7 @@ std::pair ForwardMeasurementEstimator::estimate float myPhimin = thePhiMin; float myPhimax = thePhiMax; - float phiDiff = normalized_phi(rhPhi - tsPhi) ; + float phiDiff = normalizedPhi(rhPhi - tsPhi) ; if ( phiDiff < myPhimax && phiDiff > myPhimin ) { return std::pair(true,1.) ; } diff --git a/RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc b/RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc index 07e9177bcf0df..46849148cec7f 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc @@ -83,7 +83,7 @@ void GsfElectronAlgo::ElectronData::computeCharge GlobalVector scvect(scpos-orig) ; GlobalPoint inntkpos = innTSOS.globalPosition() ; GlobalVector inntkvect = GlobalVector(inntkpos-orig) ; - float dPhiInnEle=normalized_phi(scvect.barePhi()-inntkvect.barePhi()) ; + float dPhiInnEle=normalizedPhi(scvect.barePhi()-inntkvect.barePhi()) ; if(dPhiInnEle>0) info.scPixCharge = -1 ; else info.scPixCharge = 1 ; @@ -716,29 +716,28 @@ void GsfElectronAlgo::createElectron(reco::GsfElectronCollection & electrons, El eventData.retreiveOriginalTrackCollections(electronData.ctfTrackRef,electronData.coreRef->gsfTrack()) ; - ConversionFinder conversionFinder ; double BInTesla = eventSetupData_.magField->inTesla(GlobalPoint(0.,0.,0.)).z() ; edm::Handle ctfTracks = eventData.originalCtfTracks ; if (!ctfTracks.isValid()) { ctfTracks = eventData.currentCtfTracks ; } - // values of conversionInfo.flag() + // values of conversionInfo.flag // -9999 : Partner track was not found // 0 : Partner track found in the CTF collection using // 1 : Partner track found in the CTF collection using // 2 : Partner track found in the GSF collection using // 3 : Partner track found in the GSF collection using the electron's GSF track - ConversionInfo conversionInfo = conversionFinder.getConversionInfo + ConversionInfo conversionInfo = egammaTools::getConversionInfo (*electronData.coreRef,ctfTracks,eventData.originalGsfTracks,BInTesla) ; reco::GsfElectron::ConversionRejection conversionVars ; - conversionVars.flags = conversionInfo.flag() ; - conversionVars.dist = conversionInfo.dist() ; - conversionVars.dcot = conversionInfo.dcot() ; - conversionVars.radius = conversionInfo.radiusOfConversion() ; + conversionVars.flags = conversionInfo.flag ; + conversionVars.dist = conversionInfo.dist ; + conversionVars.dcot = conversionInfo.dcot ; + conversionVars.radius = conversionInfo.radiusOfConversion ; if ((conversionVars.flags==0)or(conversionVars.flags==1)) - conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk()) ; + conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerCtfTk) ; else if ((conversionVars.flags==2)or(conversionVars.flags==3)) - conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk()) ; + conversionVars.partner = TrackBaseRef(conversionInfo.conversionPartnerGsfTk) ; //==================================================== diff --git a/RecoEgamma/EgammaElectronAlgos/src/PixelHitMatcher.cc b/RecoEgamma/EgammaElectronAlgos/src/PixelHitMatcher.cc index b97acc66bac22..65342b38d946d 100644 --- a/RecoEgamma/EgammaElectronAlgos/src/PixelHitMatcher.cc +++ b/RecoEgamma/EgammaElectronAlgos/src/PixelHitMatcher.cc @@ -279,7 +279,7 @@ PixelHitMatcher::compatibleHits LogDebug("") <<"[PixelHitMatcher::compatibleHits] nbr of hits compatible with extrapolation to first layer: " << pixelMeasurements.size(); for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){ if (m->recHit()->isValid()) { - float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; + float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; if(std::abs(localDphi)>2.5)continue; CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(), m->forwardPredictedState().globalPosition().y(), @@ -309,7 +309,7 @@ PixelHitMatcher::compatibleHits for (aMeas m=pixel2Measurements.begin(); m!=pixel2Measurements.end(); m++){ if (m->recHit()->isValid()) { - float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; + float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; if(std::abs(localDphi)>2.5)continue; CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(), m->forwardPredictedState().globalPosition().y(), @@ -350,7 +350,7 @@ PixelHitMatcher::compatibleHits for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){ if (m->recHit()->isValid()) { - float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()); + float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()); if(std::abs(localDphi)>2.5)continue; CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(), m->forwardPredictedState().globalPosition().y(), @@ -371,7 +371,7 @@ PixelHitMatcher::compatibleHits for (aMeas m=pixel2Measurements.begin(); m!=pixel2Measurements.end(); m++){ if (m->recHit()->isValid()) { - float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; + float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ; if(std::abs(localDphi)>2.5)continue; CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(), m->forwardPredictedState().globalPosition().y(), @@ -436,7 +436,7 @@ PixelHitMatcher::compatibleHits if(!secondHit.measurementsInNextLayers().empty()){ for(unsigned int shit=0; shitglobalPosition().barePhi()) ; + float dphi = normalizedPhi(pred1Meas[i].phi()-validMeasurements[i].recHit()->globalPosition().barePhi()) ; if (std::abs(dphi)<2.5) { ConstRecHitPointer pxrh = validMeasurements[i].recHit(); diff --git a/RecoEgamma/EgammaElectronProducers/plugins/BuildFile.xml b/RecoEgamma/EgammaElectronProducers/plugins/BuildFile.xml index 64344393af57d..f73674f445d0e 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/BuildFile.xml +++ b/RecoEgamma/EgammaElectronProducers/plugins/BuildFile.xml @@ -15,8 +15,7 @@ - - + diff --git a/RecoEgamma/EgammaElectronProducers/plugins/GEDGsfElectronProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/GEDGsfElectronProducer.cc index 2b9bf3bfb41eb..3a4bef49eb068 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/GEDGsfElectronProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/GEDGsfElectronProducer.cc @@ -21,7 +21,6 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h" -#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h" #include #include @@ -76,9 +75,8 @@ void GEDGsfElectronProducer::fillGsfElectronValueMap(edm::Event & event, edm::Va // First check that the GsfTrack is non null if( it->gsfTrackRef().isNonnull()) { // now look for the corresponding GsfElectron - GsfElectronEqual myEqual(it->gsfTrackRef()); - const reco::GsfElectronCollection::const_iterator itcheck= - std::find_if(orphanHandle()->begin(),orphanHandle()->end(),myEqual); + const auto itcheck = std::find_if( orphanHandle()->begin(),orphanHandle()->end(), + [it](const auto& ele) {return (ele.gsfTrack() == it->gsfTrackRef());} ); if (itcheck != orphanHandle()->end()) { // Build the Ref from the handle and the index myRef = reco::GsfElectronRef(orphanHandle(),itcheck-orphanHandle()->begin()); diff --git a/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronFull5x5Filler.cc b/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronFull5x5Filler.cc index 6145906e1980e..59436d5462db6 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronFull5x5Filler.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/GsfElectronFull5x5Filler.cc @@ -25,7 +25,6 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h" -#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h" #include "FWCore/Utilities/interface/isFinite.h" diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc index 4782baf7f2f32..f6e7fcf988c1a 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc @@ -18,8 +18,8 @@ #include "DataFormats/Math/interface/LorentzVector.h" #include "DataFormats/ParticleFlowReco/interface/PFTrajectoryPoint.h" #include "DataFormats/TrackReco/interface/TrackBase.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -406,15 +406,14 @@ void LowPtGsfElectronSeedProducer::propagateTrackToCalo( const reco::TrackRef& k kfTrackRef->outerPosition().z(), 0. ); math::XYZVector field(field_->inTesla(GlobalPoint(0,0,0))); - BaseParticlePropagator particle( RawParticle(mom,pos), 0, 0, field.z() ); - particle.setCharge(kfTrackRef->charge()); + BaseParticlePropagator particle( RawParticle(mom,pos,kfTrackRef->charge()), 0, 0, field.z() ); particle.propagateToEcalEntrance(false); if ( particle.getSuccess() == 0 ) { return; } // ECAL entry point for track - GlobalPoint ecal_pos(particle.vertex().x(), - particle.vertex().y(), - particle.vertex().z()); + GlobalPoint ecal_pos(particle.particle().vertex().x(), + particle.particle().vertex().y(), + particle.particle().vertex().z()); // Preshower limit bool below_ps = pow(ecal_pos.z(),2.) > boundary_*ecal_pos.perp2(); @@ -428,9 +427,9 @@ void LowPtGsfElectronSeedProducer::propagateTrackToCalo( const reco::TrackRef& k below_ps, false); GlobalPoint showerPos = ecal_pos + - GlobalVector(particle.momentum().x(), - particle.momentum().y(), - particle.momentum().z()).unit() * shower_depth; + GlobalVector(particle.particle().momentum().x(), + particle.particle().momentum().y(), + particle.particle().momentum().z()).unit() * shower_depth; // Determine dR squared float dr2 = reco::deltaR2( cluRef->positionREP(), showerPos ); diff --git a/RecoEgamma/EgammaElectronProducers/src/LowPtGsfElectronSeedHeavyObjectCache.cc b/RecoEgamma/EgammaElectronProducers/src/LowPtGsfElectronSeedHeavyObjectCache.cc index 4ddb6d9cbd612..180c282d77ea9 100644 --- a/RecoEgamma/EgammaElectronProducers/src/LowPtGsfElectronSeedHeavyObjectCache.cc +++ b/RecoEgamma/EgammaElectronProducers/src/LowPtGsfElectronSeedHeavyObjectCache.cc @@ -7,8 +7,7 @@ #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "FWCore/ParameterSet/interface/FileInPath.h" #include "RecoEgamma/EgammaElectronProducers/interface/LowPtGsfElectronSeedHeavyObjectCache.h" -//#include "TMVA/MethodBDT.h" -//#include "TMVA/Reader.h" + #include namespace lowptgsfeleseed { diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc index 1b65420d6bb3b..5dc76e868c3f1 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTElectronDetaDphiProducer.cc @@ -134,11 +134,10 @@ std::pair EgammaHLTElectronDetaDphiProducer::calDEtaDPhiSCTrk(reco: deltaphi = fabs(scAtVtx.dPhi()); } } else if (useTrackProjectionToEcal_) { - ECALPositionCalculator posCalc; const math::XYZPoint vertex(bsPosition.x(),bsPosition.y(),eleref->track()->vz()); - float phi1= posCalc.ecalPhi(magField,trackMom,vertex,1); - float phi2= posCalc.ecalPhi(magField,trackMom,vertex,-1); + float phi1 = egammaTools::ecalPhi(*magField,trackMom,vertex,1); + float phi2 = egammaTools::ecalPhi(*magField,trackMom,vertex,-1); float deltaphi1=fabs( phi1 - theClus->position().phi() ); if(deltaphi1>6.283185308) deltaphi1 -= 6.283185308; diff --git a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc index b5792b9a33c25..89edeeb61bd93 100644 --- a/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc +++ b/RecoEgamma/EgammaHLTProducers/src/EgammaHLTGsfTrackVarProducer.cc @@ -20,7 +20,6 @@ #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" #include "DataFormats/Math/interface/Point3D.h" -#include "RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "MagneticField/Engine/interface/MagneticField.h" diff --git a/RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h b/RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h index 190228d381a02..ebf69943da49b 100644 --- a/RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h +++ b/RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h @@ -2,7 +2,6 @@ #define __BASELINEPFSCREGRESSION_H__ #include "RecoEgamma/EgammaTools/interface/SCRegressionCalculator.h" -#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" #include "Geometry/CaloTopology/interface/CaloTopology.h" @@ -38,7 +37,6 @@ class BaselinePFSCRegression { private: const CaloTopologyRecord* topo_record; const CaloGeometryRecord* geom_record; - EcalClusterLocal ecl_; edm::ESHandle calotopo; edm::ESHandle calogeom; edm::EDGetTokenT inputTagEBRecHits_; diff --git a/RecoEgamma/EgammaTools/interface/ConversionFinder.h b/RecoEgamma/EgammaTools/interface/ConversionFinder.h index e9bc969a066c1..ea06a3ea4d7a8 100644 --- a/RecoEgamma/EgammaTools/interface/ConversionFinder.h +++ b/RecoEgamma/EgammaTools/interface/ConversionFinder.h @@ -33,10 +33,7 @@ radius of conversion for this pair and fill the ConversionInfo */ -class ConversionFinder { - public: - ConversionFinder(); - ~ConversionFinder(); +namespace egammaTools { //bField has to be supplied in Tesla //returns a vector of Conversion Infos. @@ -61,16 +58,6 @@ class ConversionFinder { const double bFieldAtOrigin, const double minFracSharedHits = 0.45); - //used internally, so call this only if you know what you're doing. - ConversionInfo getConversionInfo(const reco::Track *el_track, - const reco::Track *candPartnerTk, - const double bFieldAtOrigin); - - const reco::Track* getElectronTrack(const reco::GsfElectron &, const float minFracSharedHits = 0.45); - - const reco::Track* getElectronTrack(const reco::GsfElectronCore &, const float minFracSharedHits = 0.45); - - //takes in a vector of candidate conversion partners //and arbitrates between them returning the one with the //smallest R=sqrt(dist*dist + dcot*dcot) @@ -80,13 +67,6 @@ class ConversionFinder { //places different cuts on dist, dcot, delmissing hits and arbitration based on R = sqrt(dist*dist + dcot*dcot) ConversionInfo findBestConversionMatch(const std::vector& v_convCandidates); - //function below is only for backwards compatibility - static std::pair getConversionInfo(math::XYZTLorentzVector trk1_p4, - int trk1_q, float trk1_d0, - math::XYZTLorentzVector trk2_p4, - int trk2_q, float trk2_d0, - float bFieldAtOrigin); - //for backwards compatibility. Does not use the GSF track collection. This function will be //deprecated soon ConversionInfo getConversionInfo(const reco::GsfElectron& gsfElectron, @@ -98,7 +78,5 @@ class ConversionFinder { // DEPRECATED bool isFromConversion( const ConversionInfo &, double maxAbsDist = 0.02, double maxAbsDcot = 0.02); - private: - -}; +} #endif diff --git a/RecoEgamma/EgammaTools/interface/ConversionInfo.h b/RecoEgamma/EgammaTools/interface/ConversionInfo.h index e89c7bb46d3e8..5665cc322f860 100644 --- a/RecoEgamma/EgammaTools/interface/ConversionInfo.h +++ b/RecoEgamma/EgammaTools/interface/ConversionInfo.h @@ -1,86 +1,31 @@ #ifndef EgammaTools_ConversionInfo_h #define EgammaTools_ConversionInfo_h -#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" -//#include "DataFormats/TrackReco/interface/Track.h" -//#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "DataFormats/Math/interface/Point3D.h" -class ConversionInfo - { - public: - - ConversionInfo() - { - dist_ = -9999.; - dcot_ = -9999.; - radiusOfConversion_ = -9999.; - pointOfConversion_ = math::XYZPoint(-9999.,-9999.,-9999); - conversionPartnerCtfTk_ = reco::TrackRef(); - conversionPartnerGsfTk_ = reco::GsfTrackRef(); - deltaMissingHits_ = -9999; - flag_ = -9999; - } - ~ConversionInfo() {} - ConversionInfo - ( double dist, double dcot, - double radiusOfConversion, math::XYZPoint pointOfConversion, - reco::TrackRef conversionPartnerCtfTk, - reco::GsfTrackRef conversionPartnerGsfTk, - int deltaMissingHits, - int flag ) - { - dist_ = dist; - dcot_ = dcot; - radiusOfConversion_ = radiusOfConversion; - pointOfConversion_ = pointOfConversion; - conversionPartnerCtfTk_ = conversionPartnerCtfTk; - conversionPartnerGsfTk_ = conversionPartnerGsfTk; - deltaMissingHits_ = deltaMissingHits; - flag_ = flag; - } - double dist() const {return dist_ ; } - double dcot() const {return dcot_ ; } - double radiusOfConversion() const { return radiusOfConversion_ ; } - math::XYZPoint pointOfConversion() const { return pointOfConversion_ ; } - reco::TrackRef conversionPartnerCtfTk() const { return conversionPartnerCtfTk_ ; } - - //if the partner track is found in the GSF track collection, - //we return a ref to the GSF partner track - reco::GsfTrackRef conversionPartnerGsfTk() const { return conversionPartnerGsfTk_ ; } - - //if the partner track is found in the CTF track collection, - //we return a ref to the CTF partner track - int deltaMissingHits() const { return deltaMissingHits_ ; } - /* - if(flag == 0) //Partner track found in the CTF collection using the electron's CTF track - if(flag == 1) //Partner track found in the CTF collection using the electron's GSF track - if(flag == 2) //Partner track found in the GSF collection using the electron's CTF track - if(flag == 3) //Partner track found in the GSF collection using the electron's GSF track - */ - int flag() const { return flag_ ; } - - reco::TrackRef conversionPartnerTk() const { - edm::LogWarning("ConversionInfo") << "The conversionPartnerTk() function is deprecated, but still returns the CTF partner track if found! \n" - << "Please use either conversionPartnerCtfTk() and conversionPartnerGsfTk() instead. \n"; - return conversionPartnerCtfTk_; - } - - private: - - double dist_; - double dcot_; - double radiusOfConversion_; - math::XYZPoint pointOfConversion_; - reco::TrackRef conversionPartnerCtfTk_; - reco::GsfTrackRef conversionPartnerGsfTk_; - int deltaMissingHits_; - int flag_; - - } ; +struct ConversionInfo +{ + const double dist; + const double dcot; + const double radiusOfConversion; + const math::XYZPoint pointOfConversion; + // if the partner track is found in the GSF track collection, + // this is a ref to the GSF partner track + const reco::TrackRef conversionPartnerCtfTk; + // if the partner track is found in the CTF track collection, + // this is a ref to the CTF partner track + const reco::GsfTrackRef conversionPartnerGsfTk; + const int deltaMissingHits; + const int flag; + + // flag 0: Partner track found in the CTF collection using the electron's CTF track + // flag 1: Partner track found in the CTF collection using the electron's GSF track + // flag 2: Partner track found in the GSF collection using the electron's CTF track + // flag 3: Partner track found in the GSF collection using the electron's GSF track +}; #endif diff --git a/RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h b/RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h index 843dae4ae4309..e0835829de585 100644 --- a/RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h +++ b/RecoEgamma/EgammaTools/interface/ECALPositionCalculator.h @@ -6,14 +6,10 @@ class MagneticField; -class ECALPositionCalculator +namespace egammaTools { - public: - ECALPositionCalculator() { }; - double ecalPhi(const MagneticField *magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge); - double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex); - private: - + double ecalPhi(const MagneticField &magField, const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge); + double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex); }; #endif diff --git a/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h b/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h index 1c28caf87d3d3..3ce210c6c7f16 100644 --- a/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h +++ b/RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h @@ -14,7 +14,6 @@ #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h" class GBRForest; @@ -43,8 +42,6 @@ class EGEnergyCorrector { Bool_t fOwnsForests; Float_t *fVals; - EcalClusterLocal _ecalLocal; - }; diff --git a/RecoEgamma/EgammaTools/interface/EcalClusterLocal.h b/RecoEgamma/EgammaTools/interface/EcalClusterLocal.h index f5d698d3c841b..785215aa30654 100644 --- a/RecoEgamma/EgammaTools/interface/EcalClusterLocal.h +++ b/RecoEgamma/EgammaTools/interface/EcalClusterLocal.h @@ -8,22 +8,16 @@ */ -//#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/Frameworkfwd.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" class CaloGeometry; -class EcalClusterLocal { - public: - EcalClusterLocal(); - ~EcalClusterLocal(); +namespace egammaTools { - void localCoordsEB( const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const; - void localCoordsEE( const reco::CaloCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const; - - void localCoordsEB( const reco::CaloCluster &bclus, const CaloGeometry & geom, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const; - void localCoordsEE( const reco::CaloCluster &bclus, const CaloGeometry & geom, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const; + void localEcalClusterCoordsEB( const reco::CaloCluster &bclus, const CaloGeometry & geom, float &etacry, + float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt); + void localEcalClusterCoordsEE( const reco::CaloCluster &bclus, const CaloGeometry & geom, float &xcry, + float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt); }; diff --git a/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV1.cc b/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV1.cc index 97ab414b217a3..ef308d7021505 100644 --- a/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV1.cc +++ b/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV1.cc @@ -10,6 +10,8 @@ #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Utilities/interface/InputTag.h" #include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include @@ -214,11 +216,12 @@ void EGRegressionModifierV1::modifyObject(reco::GsfElectron& ele) const { int iEta; float cryPhi; float cryEta; - EcalClusterLocal ecalLocal; + edm::ESHandle caloGeometry; + iSetup_->get().get(caloGeometry); if (ele.isEB()) - ecalLocal.localCoordsEB(*theseed, *iSetup_, cryEta, cryPhi, iEta, iPhi, dummy, dummy); + egammaTools::localEcalClusterCoordsEB(*theseed, *caloGeometry, cryEta, cryPhi, iEta, iPhi, dummy, dummy); else - ecalLocal.localCoordsEE(*theseed, *iSetup_, cryEta, cryPhi, iEta, iPhi, dummy, dummy); + egammaTools::localEcalClusterCoordsEE(*theseed, *caloGeometry, cryEta, cryPhi, iEta, iPhi, dummy, dummy); if (isEB) { eval[29] = cryEta; diff --git a/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV2.cc b/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV2.cc index c96bb677551a7..9d5cf77b7e157 100644 --- a/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV2.cc +++ b/RecoEgamma/EgammaTools/plugins/EGRegressionModifierV2.cc @@ -8,6 +8,8 @@ #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Utilities/interface/InputTag.h" #include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include @@ -162,13 +164,14 @@ void EGRegressionModifierV2::modifyObject(reco::GsfElectron& ele) const { eval[25] = std::max(0,numberOfClusters); // calculate coordinate variables - EcalClusterLocal ecalLocal; + edm::ESHandle caloGeometry; + iSetup_->get().get(caloGeometry); if (isEB) { float dummy; int ieta; int iphi; - ecalLocal.localCoordsEB(*seed, *iSetup_, dummy, dummy, ieta, iphi, dummy, dummy); + egammaTools::localEcalClusterCoordsEB(*seed, *caloGeometry, dummy, dummy, ieta, iphi, dummy, dummy); eval[26] = ieta; eval[27] = iphi; int signieta = ieta > 0 ? +1 : -1; @@ -182,7 +185,7 @@ void EGRegressionModifierV2::modifyObject(reco::GsfElectron& ele) const { float dummy; int ix; int iy; - ecalLocal.localCoordsEE(*seed, *iSetup_, dummy, dummy, ix, iy, dummy, dummy); + egammaTools::localEcalClusterCoordsEE(*seed, *caloGeometry, dummy, dummy, ix, iy, dummy, dummy); eval[26] = ix; eval[27] = iy; eval[28] = raw_es_energy/rawEnergy; @@ -354,14 +357,15 @@ void EGRegressionModifierV2::modifyObject(reco::Photon& pho) const { eval[25] = std::max(0,numberOfClusters); // calculate coordinate variables - EcalClusterLocal ecalLocal; + edm::ESHandle caloGeometry; + iSetup_->get().get(caloGeometry); if (isEB) { float dummy; int ieta; int iphi; - ecalLocal.localCoordsEB(*seed, *iSetup_, dummy, dummy, ieta, iphi, dummy, dummy); + egammaTools::localEcalClusterCoordsEB(*seed, *caloGeometry, dummy, dummy, ieta, iphi, dummy, dummy); eval[26] = ieta; eval[27] = iphi; int signieta = ieta > 0 ? +1 : -1; @@ -375,7 +379,7 @@ void EGRegressionModifierV2::modifyObject(reco::Photon& pho) const { float dummy; int ix; int iy; - ecalLocal.localCoordsEE(*seed, *iSetup_, dummy, dummy, ix, iy, dummy, dummy); + egammaTools::localEcalClusterCoordsEE(*seed, *caloGeometry, dummy, dummy, ix, iy, dummy, dummy); eval[26] = ix; eval[27] = iy; eval[28] = raw_es_energy/rawEnergy; diff --git a/RecoEgamma/EgammaTools/src/ConversionFinder.cc b/RecoEgamma/EgammaTools/src/ConversionFinder.cc index a7edfb198ed3d..4f0b77c57636b 100644 --- a/RecoEgamma/EgammaTools/src/ConversionFinder.cc +++ b/RecoEgamma/EgammaTools/src/ConversionFinder.cc @@ -5,22 +5,26 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TMath.h" +namespace egammaTools { + typedef math::XYZTLorentzVector LorentzVector; -bool ConversionFinder::isFromConversion(const ConversionInfo &convInfo, +ConversionInfo getConversionInfo(const reco::Track *el_track, + const reco::Track *candPartnerTk, + const double bFieldAtOrigin); + +const reco::Track* getElectronTrack(const reco::GsfElectron &, const float minFracSharedHits = 0.45); + +const reco::Track* getElectronTrack(const reco::GsfElectronCore &, const float minFracSharedHits = 0.45); + +bool isFromConversion(const ConversionInfo &convInfo, double maxAbsDist, double maxAbsDcot) { - return (std::abs(convInfo.dist()) < maxAbsDist) && (std::abs(convInfo.dcot()) < maxAbsDcot); + return (std::abs(convInfo.dist) < maxAbsDist) && (std::abs(convInfo.dcot) < maxAbsDcot); } //----------------------------------------------------------------------------- -ConversionFinder::ConversionFinder() {} - -//----------------------------------------------------------------------------- -ConversionFinder::~ConversionFinder() {} - -//----------------------------------------------------------------------------- -ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectron& gsfElectron, +ConversionInfo getConversionInfo(const reco::GsfElectron& gsfElectron, const edm::Handle& ctftracks_h, const edm::Handle& gsftracks_h, const double bFieldAtOrigin, @@ -31,7 +35,7 @@ ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectron& gsfE } //----------------------------------------------------------------------------- -ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectronCore& gsfElectron, +ConversionInfo getConversionInfo(const reco::GsfElectronCore& gsfElectron, const edm::Handle& ctftracks_h, const edm::Handle& gsftracks_h, const double bFieldAtOrigin, @@ -44,7 +48,7 @@ ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectronCore& //----------------------------------------------------------------------------- -std::vector ConversionFinder::getConversionInfos(const reco::GsfElectronCore& gsfElectron, +std::vector getConversionInfos(const reco::GsfElectronCore& gsfElectron, const edm::Handle& ctftracks_h, const edm::Handle& gsftracks_h, const double bFieldAtOrigin, @@ -129,16 +133,15 @@ std::vector ConversionFinder::getConversionInfos(const reco::Gsf int deltaMissingHits = ctftk->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) - el_ctftrack->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); - convInfo = ConversionInfo(convInfo.dist(), - convInfo.dcot(), - convInfo.radiusOfConversion(), - convInfo.pointOfConversion(), - TrackRef(ctftracks_h, ctftk_i), - GsfTrackRef() , - deltaMissingHits, - 0); - v_candidatePartners.push_back(convInfo); + v_candidatePartners.push_back({convInfo.dist, + convInfo.dcot, + convInfo.radiusOfConversion, + convInfo.pointOfConversion, + TrackRef(ctftracks_h, ctftk_i), + GsfTrackRef() , + deltaMissingHits, + 0}); }//using the electron's CTF track @@ -152,16 +155,15 @@ std::vector ConversionFinder::getConversionInfos(const reco::Gsf - el_gsftrack->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_gsftrack.get()), &(*ctftk), bFieldAtOrigin); - convInfo = ConversionInfo(convInfo.dist(), - convInfo.dcot(), - convInfo.radiusOfConversion(), - convInfo.pointOfConversion(), - TrackRef(ctftracks_h, ctftk_i), - GsfTrackRef(), - deltaMissingHits, - 1); - - v_candidatePartners.push_back(convInfo); + + v_candidatePartners.push_back({convInfo.dist, + convInfo.dcot, + convInfo.radiusOfConversion, + convInfo.pointOfConversion, + TrackRef(ctftracks_h, ctftk_i), + GsfTrackRef(), + deltaMissingHits, + 1}); }//using the electron's GSF track }//loop over the CTF track collection @@ -198,16 +200,14 @@ std::vector ConversionFinder::getConversionInfos(const reco::Gsf ConversionInfo convInfo = getConversionInfo((const reco::Track*)(el_ctftrack.get()), (const reco::Track*)(&(*gsftk)), bFieldAtOrigin); //fill the Ref info - convInfo = ConversionInfo(convInfo.dist(), - convInfo.dcot(), - convInfo.radiusOfConversion(), - convInfo.pointOfConversion(), - TrackRef(), - GsfTrackRef(gsftracks_h, gsftk_i), - deltaMissingHits, - 2); - v_candidatePartners.push_back(convInfo); - + v_candidatePartners.push_back({convInfo.dist, + convInfo.dcot, + convInfo.radiusOfConversion, + convInfo.pointOfConversion, + TrackRef(), + GsfTrackRef(gsftracks_h, gsftk_i), + deltaMissingHits, + 2}); } //use the electron's gsf track @@ -220,16 +220,15 @@ std::vector ConversionFinder::getConversionInfos(const reco::Gsf int deltaMissingHits = gsftk->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) - el_gsftrack->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); - convInfo = ConversionInfo(convInfo.dist(), - convInfo.dcot(), - convInfo.radiusOfConversion(), - convInfo.pointOfConversion(), - TrackRef(), - GsfTrackRef(gsftracks_h, gsftk_i), - deltaMissingHits, - 3); - v_candidatePartners.push_back(convInfo); + v_candidatePartners.push_back({convInfo.dist, + convInfo.dcot, + convInfo.radiusOfConversion, + convInfo.pointOfConversion, + TrackRef(), + GsfTrackRef(gsftracks_h, gsftk_i), + deltaMissingHits, + 3}); } }//loop over the gsf track collection @@ -240,7 +239,7 @@ std::vector ConversionFinder::getConversionInfos(const reco::Gsf //------------------------------------------------------------------------------------- -ConversionInfo ConversionFinder::getConversionInfo(const reco::Track *el_track, +ConversionInfo getConversionInfo(const reco::Track *el_track, const reco::Track *candPartnerTk, const double bFieldAtOrigin) { @@ -283,12 +282,12 @@ ConversionInfo ConversionFinder::getConversionInfo(const reco::Track *el_track, rconv = tempsign*rconv; //return an instance of ConversionInfo, but with a NULL track refs - return ConversionInfo(dist, dcot, rconv, convPoint, TrackRef(), GsfTrackRef(), -9999, -9999); + return ConversionInfo{dist, dcot, rconv, convPoint, TrackRef(), GsfTrackRef(), -9999, -9999}; } //------------------------------------------------------------------------------------- -const reco::Track* ConversionFinder::getElectronTrack(const reco::GsfElectron& electron, const float minFracSharedHits) { +const reco::Track* getElectronTrack(const reco::GsfElectron& electron, const float minFracSharedHits) { if(electron.closestCtfTrackRef().isNonnull() && electron.shFracInnerHits() > minFracSharedHits) @@ -302,38 +301,39 @@ const reco::Track* ConversionFinder::getElectronTrack(const reco::GsfElectron& e //takes in a vector of candidate conversion partners //and arbitrates between them returning the one with the //smallest R=sqrt(dist*dist + dcot*dcot) -ConversionInfo ConversionFinder::arbitrateConversionPartnersbyR(const std::vector& v_convCandidates) { +ConversionInfo arbitrateConversionPartnersbyR(const std::vector& v_convCandidates) { if(v_convCandidates.size() == 1) return v_convCandidates.at(0); - ConversionInfo arbitratedConvInfo = v_convCandidates.at(0); - double R = sqrt(pow(arbitratedConvInfo.dist(),2) + pow(arbitratedConvInfo.dcot(),2)); + double R = sqrt(pow(v_convCandidates.at(0).dist,2) + pow(v_convCandidates.at(0).dcot,2)); - for(unsigned int i = 1; i < v_convCandidates.size(); i++) { - ConversionInfo temp = v_convCandidates.at(i); - double temp_R = sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)); + int iArbitrated = 0; + int i = 0; + + for(auto const& temp : v_convCandidates) { + double temp_R = sqrt(pow(temp.dist,2) + pow(temp.dcot,2)); if(temp_R < R) { R = temp_R; - arbitratedConvInfo = temp; + iArbitrated = i; } - + ++i; } - return arbitratedConvInfo; + return v_convCandidates.at(iArbitrated); } //------------------------------------------------------------------------------------ -ConversionInfo ConversionFinder::findBestConversionMatch(const std::vector& v_convCandidates) +ConversionInfo findBestConversionMatch(const std::vector& v_convCandidates) { using namespace std; if(v_convCandidates.empty()) - return ConversionInfo(-9999.,-9999.,-9999., + return ConversionInfo{-9999.,-9999.,-9999., math::XYZPoint(-9999.,-9999.,-9999), reco::TrackRef(), reco::GsfTrackRef(), - -9999, -9999); + -9999, -9999}; if(v_convCandidates.size() == 1) @@ -347,42 +347,42 @@ ConversionInfo ConversionFinder::findBestConversionMatch(const std::vector -2) + if(fabs(temp.dist) < 0.02 && + fabs(temp.dcot) < 0.02 && + temp.deltaMissingHits < 3 && + temp.radiusOfConversion > -2) isConv = true; - if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 && - temp.deltaMissingHits() < 2 && - temp.radiusOfConversion() > -2) + if(sqrt(pow(temp.dist,2) + pow(temp.dcot,2)) < 0.05 && + temp.deltaMissingHits < 2 && + temp.radiusOfConversion > -2) isConv = true; if(isConv) v_0.push_back(temp); } - if(temp.flag() == 1) { + if(temp.flag == 1) { - if(sqrt(pow(temp.dist(),2) + pow(temp.dcot(),2)) < 0.05 && - temp.deltaMissingHits() < 2 && - temp.radiusOfConversion() > -2) + if(sqrt(pow(temp.dist,2) + pow(temp.dcot,2)) < 0.05 && + temp.deltaMissingHits < 2 && + temp.radiusOfConversion > -2) v_1.push_back(temp); } - if(temp.flag() == 2) { + if(temp.flag == 2) { - if(sqrt(pow(temp.dist(),2) + pow(temp.dcot()*temp.dcot(),2)) < 0.05 && - temp.deltaMissingHits() < 2 && - temp.radiusOfConversion() > -2) + if(sqrt(pow(temp.dist,2) + pow(temp.dcot*temp.dcot,2)) < 0.05 && + temp.deltaMissingHits < 2 && + temp.radiusOfConversion > -2) v_2.push_back(temp); } - if(temp.flag() == 3) { + if(temp.flag == 3) { - if(sqrt(temp.dist()*temp.dist() + temp.dcot()*temp.dcot()) < 0.05 - && temp.deltaMissingHits() < 2 - && temp.radiusOfConversion() > -2) + if(sqrt(temp.dist*temp.dist + temp.dcot*temp.dcot) < 0.05 + && temp.deltaMissingHits < 2 + && temp.radiusOfConversion > -2) v_3.push_back(temp); } @@ -420,7 +420,7 @@ ConversionInfo ConversionFinder::findBestConversionMatch(const std::vector ConversionFinder::getConversionInfo(LorentzVector trk1_p4, +std::pair getConversionInfo(LorentzVector trk1_p4, int trk1_q, float trk1_d0, LorentzVector trk2_p4, int trk2_q, float trk2_d0, @@ -450,7 +450,7 @@ std::pair ConversionFinder::getConversionInfo(LorentzVector trk1 //-------------------------------------- Also for backwards compatibility reasons --------------------------------------------------------------- -ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectron& gsfElectron, +ConversionInfo getConversionInfo(const reco::GsfElectron& gsfElectron, const edm::Handle& track_h, const double bFieldAtOrigin, const double minFracSharedHits) { @@ -514,10 +514,10 @@ ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectron& gsfE if(!candCtfTrackRef.isNonnull()) - return ConversionInfo(-9999.,-9999.,-9999., + return ConversionInfo{-9999.,-9999.,-9999., math::XYZPoint(-9999.,-9999.,-9999), reco::TrackRef(), reco::GsfTrackRef(), - -9999, -9999); + -9999, -9999}; @@ -561,8 +561,10 @@ ConversionInfo ConversionFinder::getConversionInfo(const reco::GsfElectron& gsfE deltaMissingHits = candCtfTrackRef->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) - el_track->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS); - return ConversionInfo(dist, dcot, rconv, convPoint, candCtfTrackRef, GsfTrackRef(), deltaMissingHits, flag); + return ConversionInfo{dist, dcot, rconv, convPoint, candCtfTrackRef, GsfTrackRef(), deltaMissingHits, flag}; } +} + //------------------------------------------------------------------------------------- diff --git a/RecoEgamma/EgammaTools/src/ECALPositionCalculator.cc b/RecoEgamma/EgammaTools/src/ECALPositionCalculator.cc index 346fb23209b4d..2d95dcff060fe 100644 --- a/RecoEgamma/EgammaTools/src/ECALPositionCalculator.cc +++ b/RecoEgamma/EgammaTools/src/ECALPositionCalculator.cc @@ -7,11 +7,13 @@ #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "MagneticField/Engine/interface/MagneticField.h" -static const float R_ECAL = 136.5; -static const float Z_Endcap = 328.0; -static const float etaBarrelEndcap = 1.479; +static constexpr float R_ECAL = 136.5; +static constexpr float Z_Endcap = 328.0; +static constexpr float etaBarrelEndcap = 1.479; -double ECALPositionCalculator::ecalPhi(const MagneticField *magField,const math::XYZVector &momentum, const math::XYZPoint &vertex, int charge) +namespace egammaTools { + +double ecalPhi(const MagneticField &magField,const math::XYZVector &momentum, const math::XYZPoint &vertex, const int charge) { // Get kinematic variables @@ -27,7 +29,7 @@ double ECALPositionCalculator::ecalPhi(const MagneticField *magField,const math: const float ZENDM = 3.186 ; // was 3.15 , updated on 16122003 float rbend = RBARM-(vRho/100.0); //Assumed vRho in cm - float bend = 0.3 * magField->inTesla(GlobalPoint(0.,0.,0.)).z() * rbend / 2.0; + float bend = 0.3 * magField.inTesla(GlobalPoint(0.,0.,0.)).z() * rbend / 2.0; float phi = 0.0; if( fabs(etaParticle) <= etaBarrelEndcap) @@ -66,7 +68,7 @@ double ECALPositionCalculator::ecalPhi(const MagneticField *magField,const math: } -double ECALPositionCalculator::ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex) +double ecalEta(const math::XYZVector &momentum, const math::XYZPoint &vertex) { // Get kinematic variables @@ -105,3 +107,4 @@ double ECALPositionCalculator::ecalEta(const math::XYZVector &momentum, const ma } +} diff --git a/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc b/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc index 7d2b3a6d53b18..b1896f3be3912 100644 --- a/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc +++ b/RecoEgamma/EgammaTools/src/EGEnergyCorrector.cc @@ -1,4 +1,3 @@ - #include #include "RecoEgamma/EgammaTools/interface/EGEnergyCorrector.h" #include "CondFormats/EgammaObjects/interface/GBRForest.h" @@ -9,6 +8,9 @@ #include "DataFormats/Math/interface/deltaPhi.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" using namespace reco; @@ -220,7 +222,9 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithError(const Photo //seed cluster float betacry, bphicry, bthetatilt, bphitilt; int bieta, biphi; - _ecalLocal.localCoordsEB(*b,es,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); + edm::ESHandle caloGeometry; + es.get().get(caloGeometry); + egammaTools::localEcalClusterCoordsEB(*b,*caloGeometry,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); fVals[56] = bieta; //crystal ieta fVals[57] = biphi; //crystal iphi @@ -235,7 +239,8 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithError(const Photo //2nd cluster (meaningful gap corrections for converted photons) float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt; int bc2ieta, bc2iphi; - if (hasbc2) _ecalLocal.localCoordsEB(*b2,es,bc2etacry,bc2phicry,bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt); + if (hasbc2) egammaTools::localEcalClusterCoordsEB( *b2,*caloGeometry,bc2etacry,bc2phicry, + bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt ); fVals[64] = hasbc2 ? bc2ieta : 0.; fVals[65] = hasbc2 ? bc2iphi : 0.; @@ -416,7 +421,9 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithError(const GsfEl float betacry, bphicry, bthetatilt, bphitilt; int bieta, biphi; - _ecalLocal.localCoordsEB(*b,es,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); + edm::ESHandle caloGeometry; + es.get().get(caloGeometry); + egammaTools::localEcalClusterCoordsEB(*b,*caloGeometry,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); fVals[56] = bieta; fVals[57] = biphi; @@ -429,7 +436,8 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithError(const GsfEl float bc2etacry, bc2phicry, bc2thetatilt, bc2phitilt; int bc2ieta, bc2iphi; - if (hasbc2) _ecalLocal.localCoordsEB(*b2,es,bc2etacry,bc2phicry,bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt); + if (hasbc2) egammaTools::localEcalClusterCoordsEB( *b2,*caloGeometry,bc2etacry,bc2phicry, + bc2ieta,bc2iphi,bc2thetatilt,bc2phitilt ); fVals[64] = hasbc2 ? bc2ieta : 0.; fVals[65] = hasbc2 ? bc2iphi : 0.; @@ -540,7 +548,9 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithErrorV3(const Pho //seed cluster float betacry, bphicry, bthetatilt, bphitilt; int bieta, biphi; - _ecalLocal.localCoordsEB(*b,es,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); + edm::ESHandle caloGeometry; + es.get().get(caloGeometry); + egammaTools::localEcalClusterCoordsEB(*b,*caloGeometry,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); fVals[30] = bieta; //crystal ieta fVals[31] = biphi; //crystal iphi @@ -702,7 +712,9 @@ std::pair EGEnergyCorrector::CorrectedEnergyWithErrorV3(const Gsf //seed cluster float betacry, bphicry, bthetatilt, bphitilt; int bieta, biphi; - _ecalLocal.localCoordsEB(*b,es,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); + edm::ESHandle caloGeometry; + es.get().get(caloGeometry); + egammaTools::localEcalClusterCoordsEB(*b,*caloGeometry,betacry,bphicry,bieta,biphi,bthetatilt,bphitilt); fVals[30] = bieta; //crystal ieta fVals[31] = biphi; //crystal iphi diff --git a/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc b/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc index 70a4d783d10bc..8a4f93f4ed5c1 100644 --- a/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc +++ b/RecoEgamma/EgammaTools/src/EcalClusterLocal.cc @@ -1,8 +1,4 @@ #include "RecoEgamma/EgammaTools/interface/EcalClusterLocal.h" - -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/CaloGeometry/interface/TruncatedPyramid.h" #include "DataFormats/EcalDetId/interface/EBDetId.h" @@ -13,22 +9,10 @@ #include "TMath.h" #include "TVector2.h" -EcalClusterLocal::EcalClusterLocal() -{} - -EcalClusterLocal::~EcalClusterLocal() -{} - -void EcalClusterLocal::localCoordsEB( const reco::CaloCluster &bclus, const edm::EventSetup &es, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const { - edm::ESHandle pG; - es.get().get(pG); - localCoordsEB( bclus, *pG, etacry, phicry, ieta, iphi, thetatilt, phitilt); -} - - +namespace egammaTools { - -void EcalClusterLocal::localCoordsEB( const reco::CaloCluster &bclus, const CaloGeometry & caloGeometry, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt) const +void localEcalClusterCoordsEB( const reco::CaloCluster &bclus, const CaloGeometry & caloGeometry, + float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt ) { assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalBarrel); @@ -96,14 +80,8 @@ void EcalClusterLocal::localCoordsEB( const reco::CaloCluster &bclus, const Calo } -void EcalClusterLocal::localCoordsEE( const reco::CaloCluster &bclus, const edm::EventSetup &es, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const -{ - edm::ESHandle pG; - es.get().get(pG); - localCoordsEE( bclus, *pG, xcry, ycry, ix, iy, thetatilt, phitilt); -} - -void EcalClusterLocal::localCoordsEE( const reco::CaloCluster &bclus, const CaloGeometry & caloGeometry, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt) const +void localEcalClusterCoordsEE( const reco::CaloCluster &bclus, const CaloGeometry & caloGeometry, + float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt ) { assert(bclus.hitsAndFractions().at(0).first.subdetId()==EcalEndcap); @@ -172,3 +150,5 @@ void EcalClusterLocal::localCoordsEE( const reco::CaloCluster &bclus, const Calo return; } + +} diff --git a/RecoEgamma/EgammaTools/src/EcalRegressionData.cc b/RecoEgamma/EgammaTools/src/EcalRegressionData.cc index b4c6dd339e7a0..c6a72fa7794e4 100644 --- a/RecoEgamma/EgammaTools/src/EcalRegressionData.cc +++ b/RecoEgamma/EgammaTools/src/EcalRegressionData.cc @@ -85,18 +85,11 @@ void EcalRegressionData::fill(const reco::SuperCluster& superClus, else if(localCovs[1]>0) sigmaIEtaIPhi_ = 1.; else sigmaIEtaIPhi_ = -1.; + auto localCoordsFunc = isEB() ? egammaTools::localEcalClusterCoordsEB : egammaTools::localEcalClusterCoordsEE; - EcalClusterLocal ecalClusterLocal; //not clear why this doesnt use static functions - float thetaTilt=0,phiTilt=0; //dummy variables that are not used but are required by below function - void (EcalClusterLocal::*localCoordFunc)(const reco::CaloCluster &, const CaloGeometry &, - float &, float &, int &, int &, - float &, float &)const; - localCoordFunc = &EcalClusterLocal::localCoordsEB; - if(!isEB()) localCoordFunc = &EcalClusterLocal::localCoordsEE; - (ecalClusterLocal.*localCoordFunc)(*superClus.seed(),*geom, - seedCrysEtaOrX_,seedCrysPhiOrY_, - seedCrysIEtaOrIX_,seedCrysIPhiOrIY_, - thetaTilt,phiTilt); + float dummy; + localCoordsFunc( *superClus.seed(),*geom, seedCrysEtaOrX_,seedCrysPhiOrY_, + seedCrysIEtaOrIX_,seedCrysIPhiOrIY_, dummy, dummy ); for( auto clus = superClus.clustersBegin()+1;clus != superClus.clustersEnd(); ++clus ) { const float dEta = (*clus)->eta() - superClus.seed()->eta(); diff --git a/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc b/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc index ddb5fabdc5120..f5410eb8972a6 100644 --- a/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc +++ b/RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc @@ -1,7 +1,6 @@ #include "RecoEgamma/ElectronIdentification/interface/CutBasedElectronID.h" #include "DataFormats/EgammaReco/interface/BasicCluster.h" #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -//#include "RecoEgamma/EgammaTools/interface/ConversionFinder.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" #include @@ -26,7 +25,7 @@ void CutBasedElectronID::setup(const edm::ParameterSet& conf) { newCategories_ = conf.getParameter("additionalCategories"); } - if (type_ == "classbased" and (version_ == "V03" or version_ == "V04" or version_ == "V05" or version_ == "")) { + if (type_ == "classbased" and (version_ == "V03" or version_ == "V04" or version_ == "V05" or version_.empty())) { wantBinning_ = conf.getParameter("etBinning"); newCategories_ = conf.getParameter("additionalCategories"); } @@ -329,7 +328,7 @@ double CutBasedElectronID::cicSelection(const reco::GsfElectron* electron, return result; } - if (type_ == "classbased" && (version_ == "V06" || version_ == "")) { + if (type_ == "classbased" && (version_ == "V06" || version_.empty())) { std::vector cutIsoSum = cuts_.getParameter >("cutiso_sum"); std::vector cutIsoSumCorr = cuts_.getParameter >("cutiso_sumoet"); std::vector cuthoe = cuts_.getParameter >("cuthoe"); diff --git a/RecoHI/HiCentralityAlgos/plugins/HiTrivialConditionRetriever.cc b/RecoHI/HiCentralityAlgos/plugins/HiTrivialConditionRetriever.cc index 999ec6a2f1f61..851b6e9281db6 100644 --- a/RecoHI/HiCentralityAlgos/plugins/HiTrivialConditionRetriever.cc +++ b/RecoHI/HiCentralityAlgos/plugins/HiTrivialConditionRetriever.cc @@ -98,7 +98,7 @@ HiTrivialConditionRetriever::produceTable( const HeavyIonRcd& ){ i++; } - return std::move(CT); + return CT; } void HiTrivialConditionRetriever::printBin(const CentralityTable::CBin* thisBin){ diff --git a/RecoJets/JetProducers/src/JetSpecific.cc b/RecoJets/JetProducers/src/JetSpecific.cc index a33f4461a26f8..50c4782e6c124 100644 --- a/RecoJets/JetProducers/src/JetSpecific.cc +++ b/RecoJets/JetProducers/src/JetSpecific.cc @@ -26,9 +26,6 @@ #include -using namespace std; - - //////////////////////////////////////////////////////////////////////////////// // implementation of global functions //////////////////////////////////////////////////////////////////////////////// @@ -132,7 +129,7 @@ void reco::writeSpecific(reco::PFClusterJet & jet, //______________________________________________________________________________ -bool reco::makeSpecific(vector const & towers, +bool reco::makeSpecific(std::vector const & towers, const CaloSubdetectorGeometry* towerGeometry, CaloJet::Specific* caloJetSpecific, const HcalTopology &topology) @@ -142,8 +139,8 @@ bool reco::makeSpecific(vector const & towers, // 1.- Loop over the tower Ids, // 2.- Get the corresponding CaloTower // 3.- Calculate the different CaloJet specific quantities - vector eECal_i; - vector eHCal_i; + std::vector eECal_i; + std::vector eHCal_i; double eInHad = 0.; double eInEm = 0.; double eInHO = 0.; @@ -155,7 +152,7 @@ bool reco::makeSpecific(vector const & towers, double eInEE = 0.; double jetArea = 0.; - vector::const_iterator itTower; + std::vector::const_iterator itTower; for (itTower=towers.begin();itTower!=towers.end();++itTower) { if ( itTower->isNull() || !itTower->isAvailable() ) { edm::LogWarning("DataNotFound") << " JetSpecific: Tower is invalid\n"; @@ -225,8 +222,8 @@ bool reco::makeSpecific(vector const & towers, caloJetSpecific->mMaxEInHadTowers = 0; //Sort the arrays - sort(eECal_i.begin(), eECal_i.end(), greater()); - sort(eHCal_i.begin(), eHCal_i.end(), greater()); + sort(eECal_i.begin(), eECal_i.end(), std::greater()); + sort(eHCal_i.begin(), eHCal_i.end(), std::greater()); if (!towers.empty()) { //Highest value in the array is the first element of the array @@ -239,7 +236,7 @@ bool reco::makeSpecific(vector const & towers, //______________________________________________________________________________ -bool reco::makeSpecific(vector const & particles, +bool reco::makeSpecific(std::vector const & particles, PFJet::Specific* pfJetSpecific) { if (nullptr==pfJetSpecific) return false; @@ -271,7 +268,7 @@ bool reco::makeSpecific(vector const & particles, float HOEnergy=0.; - vector::const_iterator itParticle; + std::vector::const_iterator itParticle; for (itParticle=particles.begin();itParticle!=particles.end();++itParticle){ if ( itParticle->isNull() || !itParticle->isAvailable() ) { edm::LogWarning("DataNotFound") << " JetSpecific: PF Particle is invalid\n"; @@ -374,50 +371,89 @@ bool reco::makeSpecific(vector const & particles, //______________________________________________________________________________ -bool reco::makeSpecific(vector const & mcparticles, +bool reco::makeSpecific(std::vector const & mcparticles, GenJet::Specific* genJetSpecific) { if (nullptr==genJetSpecific) return false; - vector::const_iterator itMcParticle=mcparticles.begin(); + std::vector::const_iterator itMcParticle=mcparticles.begin(); for (;itMcParticle!=mcparticles.end();++itMcParticle) { if ( itMcParticle->isNull() || !itMcParticle->isAvailable() ) { edm::LogWarning("DataNotFound") << " JetSpecific: MC Particle is invalid\n"; continue; } + + const Candidate* candidate = itMcParticle->get(); if (candidate->hasMasterClone()) candidate = candidate->masterClone().get(); //const GenParticle* genParticle = GenJet::genParticle(candidate); + + if (candidate) { double e = candidate->energy(); - switch (abs (candidate->pdgId ())) { - case 22: // photon - case 11: // e - genJetSpecific->m_EmEnergy += e; - break; - case 211: // pi - case 321: // K - case 130: // KL - case 2212: // p - case 2112: // n - genJetSpecific->m_HadEnergy += e; - break; - case 13: // muon - case 12: // nu_e - case 14: // nu_mu - case 16: // nu_tau - - genJetSpecific->m_InvisibleEnergy += e; - break; - default: - genJetSpecific->m_AuxiliaryEnergy += e; + + // Legacy calo-like definitions + switch (std::abs (candidate->pdgId ())) { + case 22: // photon + case 11: // e + genJetSpecific->m_EmEnergy += e; + break; + case 211: // pi + case 321: // K + case 130: // KL + case 2212: // p + case 2112: // n + genJetSpecific->m_HadEnergy += e; + break; + case 13: // muon + case 12: // nu_e + case 14: // nu_mu + case 16: // nu_tau + genJetSpecific->m_InvisibleEnergy += e; + break; + default: + genJetSpecific->m_AuxiliaryEnergy += e; } - } + + // PF-like definitions + switch (std::abs (candidate->pdgId ())) { + case 11: //electron + genJetSpecific->m_ChargedEmEnergy += e; + ++(genJetSpecific->m_ChargedEmMultiplicity); + break; + case 13: // muon + genJetSpecific->m_MuonEnergy += e; + ++(genJetSpecific->m_MuonMultiplicity); + case 211: //pi+- + case 321: //K + case 2212: //p + case 3222: //Sigma+ + case 3112: //Sigma- + case 3312: //Xi- + case 3334: //Omega- + genJetSpecific->m_ChargedHadronEnergy += e; + ++(genJetSpecific->m_ChargedHadronMultiplicity); + break; + case 310: //KS0 + case 130: //KL0 + case 3122: //Lambda0 + case 3212: //Sigma0 + case 3322: //Xi0 + case 2112: //n0 + genJetSpecific->m_NeutralHadronEnergy += e; + ++(genJetSpecific->m_NeutralHadronMultiplicity); + break; + case 22: //photon + genJetSpecific->m_NeutralEmEnergy += e; + ++(genJetSpecific->m_NeutralEmMultiplicity); + break; + } + } // end if found a candidate else { edm::LogWarning("DataNotFound") <<"reco::makeGenJetSpecific: Referred GenParticleCandidate " <<"is not available in the event\n"; } - } + }// end for loop over MC particles return true; } diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h index a089d11e62117..0d0db119a986d 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h @@ -24,6 +24,8 @@ #include "KDTreeLinkerAlgoT.h" +//Density collection +typedef std::map< DetId, float > Density; template std::vector sorted_indices(const std::vector &v) { @@ -41,6 +43,19 @@ std::vector sorted_indices(const std::vector &v) { return idx; } +template +size_t max_index(const std::vector &v) { + + // initialize original index locations + std::vector idx(v.size(),0); + std::iota (std::begin(idx), std::end(idx), 0); + + // take the max index based on comparing values in v + auto maxidx = std::max_element(idx.begin(), idx.end(), [&v](size_t i1, size_t i2) {return v[i1].data.rho < v[i2].data.rho;}); + + return (*maxidx); +} + class HGCalImagingAlgo { @@ -161,6 +176,9 @@ void reset(){ } void computeThreshold(); +//getDensity + Density getDensity(); + /// point in the space typedef math::XYZPoint Point; @@ -195,6 +213,9 @@ hgcal::RecHitTools rhtools_; // The algo id reco::CaloCluster::AlgoId algoId_; +// For keeping the density per hit + Density density_; + // various parameters used for calculating the noise levels for a given sensor (and whether to use them) bool dependSensor_; std::vector dEdXweights_; @@ -204,7 +225,7 @@ double fcPerEle_; std::vector nonAgedNoises_; double noiseMip_; std::vector > thresholds_; -std::vector > v_sigmaNoise_; +std::vector > sigmaNoise_; // The verbosity level VerbosityLevel verbosity_; @@ -297,6 +318,9 @@ double calculateDistanceToHigher(std::vector &) const; int findAndAssignClusters(std::vector &, KDTree &, double, KDTreeBox &, const unsigned int, std::vector >&) const; math::XYZPoint calculatePosition(std::vector &) const; +//For keeping the density information + void setDensity(const std::vector &nd); + // attempt to find subclusters within a given set of hexels std::vector findLocalMaximaInCluster(const std::vector&); math::XYZPoint calculatePositionWithFraction(const std::vector&, const std::vector&); diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc index b93d71af50cf9..18198771ef1f7 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalImagingAlgo.cc @@ -37,7 +37,7 @@ void HGCalImagingAlgo::populate(const HGCRecHitCollection &hits) { if (thickness_index == -1) thickness_index = 3; double storedThreshold = thresholds_[layer - 1][thickness_index]; - sigmaNoise = v_sigmaNoise_[layer - 1][thickness_index]; + sigmaNoise = sigmaNoise_[layer - 1][thickness_index]; if (hgrh.energy() < storedThreshold) continue; // this sets the ZS threshold at ecut times the sigma noise @@ -98,6 +98,8 @@ void HGCalImagingAlgo::makeClusters() { double maxdensity = calculateLocalDensity( points_[i], hit_kdtree, actualLayer); // also stores rho (energy // density) for each point (node) + //Now that we have the density per point we can store it + setDensity(points_[i]); // calculate distance to nearest point with higher density storing // distance (delta) and point's index calculateDistanceToHigher(points_[i]); @@ -115,6 +117,9 @@ std::vector HGCalImagingAlgo::getClusters(bool doSharing) { for (unsigned int i = 0; i < clsOnLayer.size(); ++i) { double energy = 0; Point position; + + //Will save the maximum density hit of the cluster + size_t rsmax = max_index(clsOnLayer[i]); if (doSharing) { @@ -158,7 +163,8 @@ std::vector HGCalImagingAlgo::getClusters(bool doSharing) { } clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); - thisCluster.clear(); + if (!clusters_v_.empty()){ clusters_v_.back().setSeed( clsOnLayer[i][rsmax].data.detid); } + thisCluster.clear(); } } else { position = calculatePosition(clsOnLayer[i]); // energy-weighted position @@ -178,6 +184,7 @@ std::vector HGCalImagingAlgo::getClusters(bool doSharing) { std::cout << "*****************************" << std::endl; } clusters_v_.emplace_back(energy, position, caloID, thisCluster, algoId_); + if (!clusters_v_.empty()){ clusters_v_.back().setSeed( clsOnLayer[i][rsmax].data.detid); } thisCluster.clear(); } } @@ -652,7 +659,7 @@ void HGCalImagingAlgo::computeThreshold() { const unsigned maxNumberOfThickIndices = 3; dummy.resize(maxNumberOfThickIndices + 1, 0); // +1 to accomodate for the Scintillators thresholds_.resize(maxlayer, dummy); - v_sigmaNoise_.resize(maxlayer, dummy); + sigmaNoise_.resize(maxlayer, dummy); for (unsigned ilayer = 1; ilayer <= maxlayer; ++ilayer) { for (unsigned ithick = 0; ithick < maxNumberOfThickIndices; ++ithick) { @@ -660,11 +667,25 @@ void HGCalImagingAlgo::computeThreshold() { 0.001f * fcPerEle_ * nonAgedNoises_[ithick] * dEdXweights_[ilayer] / (fcPerMip_[ithick] * thicknessCorrection_[ithick]); thresholds_[ilayer - 1][ithick] = sigmaNoise * ecut_; - v_sigmaNoise_[ilayer - 1][ithick] = sigmaNoise; + sigmaNoise_[ilayer - 1][ithick] = sigmaNoise; } float scintillators_sigmaNoise = 0.001f * noiseMip_ * dEdXweights_[ilayer]; thresholds_[ilayer - 1][maxNumberOfThickIndices] = ecut_ * scintillators_sigmaNoise; - v_sigmaNoise_[ilayer -1][maxNumberOfThickIndices] = scintillators_sigmaNoise; + sigmaNoise_[ilayer -1][maxNumberOfThickIndices] = scintillators_sigmaNoise; } } + +void HGCalImagingAlgo::setDensity(const std::vector &nd){ + + // for each node calculate local density rho and store it + for (auto &i : nd){ + density_[ i.data.detid ] = i.data.rho ; + } // end loop nodes +} + +//Density +Density HGCalImagingAlgo::getDensity(){ + return density_; +} + diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index f76f1636a7ecb..aeb155b8029c1 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -108,6 +108,8 @@ HGCalLayerClusterProducer::HGCalLayerClusterProducer(const edm::ParameterSet &ps produces >(); produces >("sharing"); + //density + produces< Density >(); //time for layer clusters produces > (timeClname); @@ -168,6 +170,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, std::unique_ptr > clusters( new std::vector ), clusters_sharing( new std::vector ); + auto density = std::make_unique(); algo->reset(); @@ -218,6 +221,11 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, auto clusterHandle = evt.put(std::move(clusters)); auto clusterHandleSharing = evt.put(std::move(clusters_sharing),"sharing"); + + //Keep the density + *density = algo->getDensity(); + evt.put(std::move(density)); + edm::PtrVector clusterPtrs, clusterPtrsSharing; std::vector times; diff --git a/RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h b/RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h index b1825ce880bc9..5848a102904ff 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/SimpleHBHEPhase1Algo.h @@ -45,6 +45,7 @@ class SimpleHBHEPhase1Algo : public AbsHBHEPhase1Algo float phaseNS, float timeShift, bool correctForPhaseContainment, + bool applyLegacyHBMCorrection, std::unique_ptr m2, std::unique_ptr detFit, std::unique_ptr mahi); @@ -98,6 +99,7 @@ class SimpleHBHEPhase1Algo : public AbsHBHEPhase1Algo float timeShift_; int runnum_; bool corrFPC_; + bool applyLegacyHBMCorrection_; // "Metod 2" algorithm std::unique_ptr psFitOOTpuCorr_; diff --git a/RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h b/RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h index 2008fd87f7426..228d9f527c174 100644 --- a/RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h +++ b/RecoLocalCalo/HcalRecAlgos/interface/parseHBHEPhase1AlgoDescription.h @@ -3,6 +3,7 @@ #include #include "RecoLocalCalo/HcalRecAlgos/interface/AbsHBHEPhase1Algo.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" namespace edm { class ParameterSet; @@ -18,4 +19,11 @@ namespace edm { std::unique_ptr parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps); +// +// Parameter descriptions for "parseHBHEPhase1AlgoDescription". +// Keep implementation of this function is sync with +// "parseHBHEPhase1AlgoDescription". +// +edm::ParameterSetDescription fillDescriptionForParseHBHEPhase1Algo(); + #endif // RecoLocalCalo_HcalRecAlgos_parseHBHEPhase1AlgoDescription_h diff --git a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc index e977e38afbc43..25ee87b95b463 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/MahiFit.cc @@ -96,10 +96,8 @@ void MahiFit::phase1Apply(const HBHEChannelInfo& channelData, } } + useTriple=false; if(tstrig >= ts4Thresh_ && tsTOT > 0) { - - useTriple=false; - // only do pre-fit with 1 pulse if chiSq threshold is positive if (chiSqSwitch_>0) { doFit(reconstructedVals,1); diff --git a/RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc b/RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc index bf674961c30bd..7fc155d93ff12 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc @@ -23,6 +23,7 @@ SimpleHBHEPhase1Algo::SimpleHBHEPhase1Algo( const float phaseNS, const float timeShift, const bool correctForPhaseContainment, + const bool applyLegacyHBMCorrection, std::unique_ptr m2, std::unique_ptr detFit, std::unique_ptr mahi) @@ -33,6 +34,7 @@ SimpleHBHEPhase1Algo::SimpleHBHEPhase1Algo( timeShift_(timeShift), runnum_(0), corrFPC_(correctForPhaseContainment), + applyLegacyHBMCorrection_(applyLegacyHBMCorrection), psFitOOTpuCorr_(std::move(m2)), hltOOTpuCorr_(std::move(detFit)), mahiOOTpuCorr_(std::move(mahi)) @@ -161,7 +163,7 @@ float SimpleHBHEPhase1Algo::hbminusCorrectionFactor(const HcalDetId& cell, const bool isRealData) const { float corr = 1.f; - if (isRealData && runnum_ > 0) + if (applyLegacyHBMCorrection_ && isRealData && runnum_ > 0) if (cell.subdet() == HcalBarrel) { const int ieta = cell.ieta(); @@ -217,7 +219,7 @@ float SimpleHBHEPhase1Algo::m0Time(const HBHEChannelInfo& info, // Simplified evaluation for Phase1 float emax0 = info.tsEnergy(maxI); - float emax1 = 0.; + float emax1 = 0.f; if(maxI < (nSamples - 1U)) emax1 = info.tsEnergy(maxI + 1U); // consider soi reference for collisions @@ -225,7 +227,7 @@ float SimpleHBHEPhase1Algo::m0Time(const HBHEChannelInfo& info, if(nSamplesToExamine < (int)nSamples) position -= soi; time = 25.f * (float)position; - if(emax0 > 0.f && emax1 > 0.f && maxI < (nSamples - 1U)) time += 25.f * emax1/(emax0+emax1); // 1st order corr. + if(emax0 > 0.f && emax1 > 0.f) time += 25.f * emax1/(emax0+emax1); // 1st order corr. // TimeSlew correction time -= hcalTimeSlew_delay_->delay(std::max(1.0, fc_ampl), HcalTimeSlew::Medium); diff --git a/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc b/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc index c71488d4fb089..0c43cd2e974c2 100644 --- a/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc +++ b/RecoLocalCalo/HcalRecAlgos/src/parseHBHEPhase1AlgoDescription.cc @@ -125,9 +125,30 @@ parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps) ps.getParameter("correctionPhaseNS"), ps.getParameter("tdcTimeShift"), ps.getParameter ("correctForPhaseContainment"), + ps.getParameter ("applyLegacyHBMCorrection"), std::move(m2), std::move(detFit), std::move(mahi)) ); } return algo; } + + +edm::ParameterSetDescription fillDescriptionForParseHBHEPhase1Algo() +{ + edm::ParameterSetDescription desc; + + desc.setAllowAnything(); + desc.add("Class", "SimpleHBHEPhase1Algo"); + desc.add("useM2", false); + desc.add("useM3", true); + desc.add("useMahi", true); + desc.add("firstSampleShift", 0); + desc.add("samplesToAdd", 2); + desc.add("correctionPhaseNS", 6.0); + desc.add("tdcTimeShift", 0.0); + desc.add("correctForPhaseContainment", true); + desc.add("applyLegacyHBMCorrection", true); + + return desc; +} diff --git a/RecoLocalCalo/HcalRecProducers/python/HBHEPhase1Reconstructor_cfi.py b/RecoLocalCalo/HcalRecProducers/python/HBHEPhase1Reconstructor_cfi.py index 42c9b3d59a05f..f24ee727b3181 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HBHEPhase1Reconstructor_cfi.py +++ b/RecoLocalCalo/HcalRecProducers/python/HBHEPhase1Reconstructor_cfi.py @@ -75,7 +75,10 @@ useM3 = cms.bool(True), # Use Mahi? - useMahi = cms.bool(True) + useMahi = cms.bool(True), + + # Apply legacy HB- energy correction? + applyLegacyHBMCorrection = cms.bool(True) ), # Reconstruction algorithm configuration data to fetch from DB, if any @@ -108,3 +111,6 @@ from Configuration.Eras.Modifier_run2_HE_2017_cff import run2_HE_2017 run2_HE_2017.toModify(hbheprereco, saveEffectivePedestal = cms.bool(True)) + +from Configuration.Eras.Modifier_run3_HB_cff import run3_HB +run3_HB.toModify(hbheprereco, algorithm = dict(applyLegacyHBMCorrection = cms.bool(False))) diff --git a/RecoLocalCalo/HcalRecProducers/src/HBHEPhase1Reconstructor.cc b/RecoLocalCalo/HcalRecProducers/src/HBHEPhase1Reconstructor.cc index c1cbc3c0eea59..cd2ec0424ab6f 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HBHEPhase1Reconstructor.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HBHEPhase1Reconstructor.cc @@ -788,7 +788,7 @@ HBHEPhase1Reconstructor::fillDescriptions(edm::ConfigurationDescriptions& descri desc.add("setLegacyFlagsQIE8"); desc.add("setLegacyFlagsQIE11"); - add_param_set(algorithm); + desc.add("algorithm", fillDescriptionForParseHBHEPhase1Algo()); add_param_set(flagParametersQIE8); add_param_set(flagParametersQIE11); add_param_set(pulseShapeParametersQIE8); diff --git a/RecoLocalMuon/GEMRecHit/BuildFile.xml b/RecoLocalMuon/GEMRecHit/BuildFile.xml index 5ef11428fb42b..68aafe18bb4f0 100644 --- a/RecoLocalMuon/GEMRecHit/BuildFile.xml +++ b/RecoLocalMuon/GEMRecHit/BuildFile.xml @@ -1,19 +1,15 @@ + + + - - - - - + - - - - - - + + + diff --git a/RecoLocalMuon/GEMRecHit/data/deadStrips.txt b/RecoLocalMuon/GEMRecHit/data/deadStrips.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/RecoLocalMuon/GEMRecHit/data/maskedStrips.txt b/RecoLocalMuon/GEMRecHit/data/maskedStrips.txt new file mode 100644 index 0000000000000..f3b7cbf5f2a72 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/data/maskedStrips.txt @@ -0,0 +1,30 @@ +671505408 1 +671505408 3 +671505408 5 +671505408 7 +671505408 9 +671505408 11 +671505408 13 +671505408 15 +671505408 17 +671505408 19 +671505408 21 +671505408 23 +671505408 25 +671505408 27 +671505408 29 +671505408 31 +671505408 33 +671505408 35 +671505408 37 +671505408 39 +671505408 41 +671505408 43 +671505408 45 +671505408 47 +671505408 49 +671505408 51 +671505408 53 +671505408 55 + +# example masking file gemId Re -1 Ri 1 St 1 La 1 Ch 29 Ro 6 rawId 671505408 diff --git a/RecoLocalMuon/GEMRecHit/src/GEMCluster.h b/RecoLocalMuon/GEMRecHit/interface/GEMCluster.h similarity index 84% rename from RecoLocalMuon/GEMRecHit/src/GEMCluster.h rename to RecoLocalMuon/GEMRecHit/interface/GEMCluster.h index 251dc3a0dbfa6..1612f43ed6338 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMCluster.h +++ b/RecoLocalMuon/GEMRecHit/interface/GEMCluster.h @@ -1,6 +1,7 @@ -#ifndef RecoLocalMuon_GEMCluster_h -#define RecoLocalMuon_GEMCluster_h +#ifndef RecoLocalMuon_GEMRecHit_GEMCluster_h +#define RecoLocalMuon_GEMRecHit_GEMCluster_h #include + class GEMCluster{ public: GEMCluster(); diff --git a/RecoLocalMuon/GEMRecHit/interface/GEMClusterContainer.h b/RecoLocalMuon/GEMRecHit/interface/GEMClusterContainer.h new file mode 100644 index 0000000000000..3618739e38a4a --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/interface/GEMClusterContainer.h @@ -0,0 +1,7 @@ +#ifndef RecoLocalMuon_GEMRecHit_GEMClusterContainer_h +#define RecoLocalMuon_GEMRecHit_GEMClusterContainer_h +#include + +class GEMCluster; +typedef std::set GEMClusterContainer; +#endif diff --git a/RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h b/RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h new file mode 100644 index 0000000000000..0107eab40a685 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h @@ -0,0 +1,17 @@ +#ifndef RecoLocalMuon_GEMRecHit_GEMClusterizer_h +#define RecoLocalMuon_GEMRecHit_GEMClusterizer_h +/** \class GEMClusterizer + * \author M. Maggi -- INFN Bari + */ + +#include "RecoLocalMuon/GEMRecHit/interface/GEMClusterContainer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMCluster.h" +#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" + +class GEMClusterizer{ + public: + GEMClusterizer() {}; + ~GEMClusterizer() {}; + GEMClusterContainer doAction(const GEMDigiCollection::Range& digiRange); +}; +#endif diff --git a/RecoLocalMuon/GEMRecHit/src/GEMEtaPartitionMask.h b/RecoLocalMuon/GEMRecHit/interface/GEMEtaPartitionMask.h similarity index 52% rename from RecoLocalMuon/GEMRecHit/src/GEMEtaPartitionMask.h rename to RecoLocalMuon/GEMRecHit/interface/GEMEtaPartitionMask.h index e1ad3e43fa355..b45eea4e457f5 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMEtaPartitionMask.h +++ b/RecoLocalMuon/GEMRecHit/interface/GEMEtaPartitionMask.h @@ -1,5 +1,5 @@ -#ifndef RecoLocalMuon_GEMEtaPartitionMask_h -#define RecoLocalMuon_GEMEtaPartitionMask_h +#ifndef RecoLocalMuon_GEMRecHit_GEMEtaPartitionMask_h +#define RecoLocalMuon_GEMRecHit_GEMEtaPartitionMask_h #include #include diff --git a/RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h b/RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h new file mode 100644 index 0000000000000..8467c8fd0e656 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h @@ -0,0 +1,21 @@ +#ifndef RecoLocalMuon_GEMRecHit_GEMMaskReClusterizer_h +#define RecoLocalMuon_GEMRecHit_GEMMaskReClusterizer_h +/** \Class GEMMaskReClusterizer + * \author J.C. Sanabria -- UniAndes, Bogota + */ + +#include "RecoLocalMuon/GEMRecHit/interface/GEMEtaPartitionMask.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMClusterContainer.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" + +class GEMMaskReClusterizer +{ + public : + GEMMaskReClusterizer() {}; + ~GEMMaskReClusterizer() {}; + GEMClusterContainer doAction(const GEMDetId& id,GEMClusterContainer& initClusters, const EtaPartitionMask& mask) const; + bool get(const EtaPartitionMask& mask,int strip) const; + +}; + +#endif diff --git a/RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h b/RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h index aa94862238c1d..a3dc6fdb41f6e 100644 --- a/RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h +++ b/RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h @@ -1,6 +1,5 @@ -#ifndef RecoLocalMuon_GEMRecHitAlgoFactory_H -#define RecoLocalMuon_GEMRecHitAlgoFactory_H - +#ifndef RecoLocalMuon_GEMRecHit_GEMRecHitAlgoFactory_H +#define RecoLocalMuon_GEMRecHit_GEMRecHitAlgoFactory_H /** \class GEMRecHitAlgoFactory * Factory of seal plugins for 1D RecHit reconstruction algorithms. * The plugins are concrete implementations of GEMRecHitBaseAlgo base class. @@ -12,7 +11,3 @@ typedef edmplugin::PluginFactory GEMRecHitAlgoFactory; #endif - - - - diff --git a/RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h b/RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h index 1ee5e3ee5080d..768e6f570f811 100644 --- a/RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h +++ b/RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h @@ -1,5 +1,5 @@ -#ifndef RecoLocalMuon_GEMRecHitBaseAlgo_H -#define RecoLocalMuon_GEMRecHitBaseAlgo_H +#ifndef RecoLocalMuon_GEMRecHit_GEMRecHitBaseAlgo_H +#define RecoLocalMuon_GEMRecHit_GEMRecHitBaseAlgo_H /** \class GEMRecHitBaseAlgo * Abstract algorithmic class to compute Rec Hit @@ -8,7 +8,6 @@ * \author M. Maggi -- INFN Bari */ - #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/GeometrySurface/interface/LocalError.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" @@ -16,8 +15,8 @@ #include "DataFormats/GEMRecHit/interface/GEMRecHit.h" #include "DataFormats/Common/interface/OwnVector.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMEtaPartitionMask.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMEtaPartitionMask.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h" class GEMCluster; class GEMEtaPartition; diff --git a/RecoLocalMuon/GEMRecHit/plugins/BuildFile.xml b/RecoLocalMuon/GEMRecHit/plugins/BuildFile.xml new file mode 100644 index 0000000000000..8bd74b183c0a1 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/plugins/BuildFile.xml @@ -0,0 +1,2 @@ + + diff --git a/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.cc b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.cc new file mode 100644 index 0000000000000..d9c7c03b911f9 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.cc @@ -0,0 +1,172 @@ +/** \file + * + * \author M. Maggi -- INFN Bari + */ +#include "RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.h" + +#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHit.h" + +#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" + +#include "CondFormats/DataRecord/interface/GEMMaskedStripsRcd.h" +#include "CondFormats/DataRecord/interface/GEMDeadStripsRcd.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include +#include + +using namespace edm; +using namespace std; + +GEMRecHitProducer::GEMRecHitProducer(const ParameterSet& config): + theGEMDigiToken(consumes(config.getParameter("gemDigiLabel"))), + // Get the concrete reconstruction algo from the factory + theAlgo{GEMRecHitAlgoFactory::get()->create(config.getParameter("recAlgo"), + config.getParameter("recAlgoConfig"))}, + maskSource_(MaskSource::EventSetup), deadSource_(MaskSource::EventSetup) +{ + produces(); + + // Get masked- and dead-strip information from file + applyMasking_ = config.getParameter("applyMasking"); + if (applyMasking_) { + if (config.existsAs("maskFile")) { + maskSource_ = MaskSource::File; + std::ifstream inputFile(config.getParameter("maskFile").fullPath()); + if ( !inputFile ) { + throw cms::Exception("GEMRecHitProducer") << "Masked Strips File cannot not be opened"; + } + theGEMMaskedStripsObj = std::make_unique(); + while ( inputFile.good() ) { + GEMMaskedStrips::MaskItem Item; + inputFile >> Item.rawId >> Item.strip; + if ( inputFile.good() ) theGEMMaskedStripsObj->fillMaskVec(Item); + + } + inputFile.close(); + } + + if (config.existsAs("deadFile")) { + deadSource_ = MaskSource::File; + std::ifstream inputFile(config.getParameter("deadFile").fullPath()); + if ( !inputFile ) { + throw cms::Exception("GEMRecHitProducer") << "Dead Strips File cannot not be opened"; + } + theGEMDeadStripsObj = std::make_unique(); + while ( inputFile.good() ) { + GEMDeadStrips::DeadItem Item; + inputFile >> Item.rawId >> Item.strip; + if ( inputFile.good() ) theGEMDeadStripsObj->fillDeadVec(Item); + } + inputFile.close(); + } + } +} + +GEMRecHitProducer::~GEMRecHitProducer() = default; + +void GEMRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) +{ + edm::ParameterSetDescription desc; + edm::ParameterSetDescription recAlgoConfigDesc; + desc.add("recAlgoConfig", recAlgoConfigDesc); + desc.add("recAlgo", "GEMRecHitStandardAlgo"); + desc.add("gemDigiLabel", edm::InputTag("muonGEMDigis")); + desc.add("applyMasking", false); + desc.addOptional("maskFile"); + desc.addOptional("deadFile"); + descriptions.add("gemRecHitsDef",desc); +} + +void GEMRecHitProducer::beginRun(const edm::Run& r, const edm::EventSetup& setup) +{ + // Get the GEM Geometry + setup.get().get(gemGeom_); + + if (applyMasking_) { + // Getting the masked-strip information + if ( maskSource_ == MaskSource::EventSetup ) { + edm::ESHandle readoutMaskedStrips; + setup.get().get(readoutMaskedStrips); + theGEMMaskedStripsObj = std::make_unique(*readoutMaskedStrips.product()); + } + // Getting the dead-strip information + if ( deadSource_ == MaskSource::EventSetup ) { + edm::ESHandle readoutDeadStrips; + setup.get().get(readoutDeadStrips); + theGEMDeadStripsObj = std::make_unique(*readoutDeadStrips.product()); + } + + for (auto gems: gemGeom_->etaPartitions()) { + // Getting the EtaPartitionMask mask, that includes dead strips, for the given GEMDet + GEMDetId gemId = gems->id(); + EtaPartitionMask mask; + const int rawId = gemId.rawId(); + for ( const auto& tomask : theGEMMaskedStripsObj->getMaskVec() ) { + if ( tomask.rawId == rawId ) { + const int bit = tomask.strip; + mask.set(bit-1); + } + } + for ( const auto& tomask : theGEMDeadStripsObj->getDeadVec() ) { + if ( tomask.rawId == rawId ) { + const int bit = tomask.strip; + mask.set(bit-1); + } + } + // add to masking map if masking present in etaPartition + if (mask.any()) { + gemMask_.emplace(gemId,mask); + } + } + } +} + +void GEMRecHitProducer::produce(Event& event, const EventSetup& setup) +{ + // Get the digis from the event + Handle digis; + event.getByToken(theGEMDigiToken,digis); + + // Pass the EventSetup to the algo + theAlgo->setES(setup); + + // Create the pointer to the collection which will store the rechits + auto recHitCollection = std::make_unique(); + + // Iterate through all digi collections ordered by LayerId + for ( auto gemdgIt = digis->begin(); gemdgIt != digis->end(); ++gemdgIt ) { + // The layerId + const GEMDetId& gemId = (*gemdgIt).first; + + // Get the GeomDet from the setup + const GEMEtaPartition* roll = gemGeom_->etaPartition(gemId); + if (roll == nullptr){ + edm::LogError("BadDigiInput")<<"Failed to find GEMEtaPartition for ID "<second; + } + + // Call the reconstruction algorithm + OwnVector recHits = theAlgo->reconstruct(*roll, gemId, range, mask); + + if(!recHits.empty()) //FIXME: is it really needed? + recHitCollection->put(gemId, recHits.begin(), recHits.end()); + } + + event.put(std::move(recHitCollection)); +} diff --git a/RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.h b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.h similarity index 54% rename from RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.h rename to RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.h index ae5cb2f23df8b..73adbdcaacc28 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.h +++ b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.h @@ -7,52 +7,37 @@ * \author M. Maggim -- INFN Bari */ - -#include -#include -#include -#include -#include -#include -#include - #include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" - -// #include "CondFormats/GEMObjects/interface/GEMMaskedStrips.h" -// #include "CondFormats/DataRecord/interface/GEMMaskedStripsRcd.h" -// #include "CondFormats/GEMObjects/interface/GEMDeadStrips.h" -// #include "CondFormats/DataRecord/interface/GEMDeadStripsRcd.h" - -#include "GEMEtaPartitionMask.h" - - -namespace edm { - class ParameterSet; - class Event; - class EventSetup; -} - -class GEMRecHitBaseAlgo; +#include "CondFormats/GEMObjects/interface/GEMMaskedStrips.h" +#include "CondFormats/GEMObjects/interface/GEMDeadStrips.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h" class GEMRecHitProducer : public edm::stream::EDProducer<> { -public: + public: /// Constructor GEMRecHitProducer(const edm::ParameterSet& config); /// Destructor ~GEMRecHitProducer() override; - + // Method that access the EventSetup for each run void beginRun(const edm::Run&, const edm::EventSetup& ) override; /// The method which produces the rechits void produce(edm::Event& event, const edm::EventSetup& setup) override; -private: + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: // The token to be used to retrieve GEM digis from the event edm::EDGetTokenT theGEMDigiToken; @@ -60,19 +45,20 @@ class GEMRecHitProducer : public edm::stream::EDProducer<> { // The reconstruction algorithm std::unique_ptr theAlgo; - // GEMMaskedStrips* GEMMaskedStripsObj; // Object with mask-strips-vector for all the GEM Detectors + std::unique_ptr theGEMMaskedStripsObj; - // GEMDeadStrips* GEMDeadStripsObj; // Object with dead-strips-vector for all the GEM Detectors + std::unique_ptr theGEMDeadStripsObj; - // std::string maskSource; - // std::string deadSource; + enum class MaskSource { File, EventSetup } maskSource_, deadSource_; - // std::vector MaskVec; - // std::vector DeadVec; + edm::ESHandle gemGeom_; -}; + // map of mask and dead strips + std::map gemMask_; + bool applyMasking_; + +}; #endif - diff --git a/RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.cc b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.cc similarity index 92% rename from RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.cc rename to RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.cc index 0c21c636943f3..4f38a2f2d563e 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.cc +++ b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.cc @@ -3,33 +3,22 @@ * * \author M. Maggi -- INFN */ - -#include "GEMCluster.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMCluster.h" +#include "RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/Exception.h" - GEMRecHitStandardAlgo::GEMRecHitStandardAlgo(const edm::ParameterSet& config) : GEMRecHitBaseAlgo(config) -{ -} - - +{} GEMRecHitStandardAlgo::~GEMRecHitStandardAlgo() -{ -} - - - -void GEMRecHitStandardAlgo::setES(const edm::EventSetup& setup) { -} - +{} +void GEMRecHitStandardAlgo::setES(const edm::EventSetup& setup) {} // First Step bool GEMRecHitStandardAlgo::compute(const GEMEtaPartition& roll, @@ -49,7 +38,6 @@ bool GEMRecHitStandardAlgo::compute(const GEMEtaPartition& roll, return true; } - bool GEMRecHitStandardAlgo::compute(const GEMEtaPartition& roll, const GEMCluster& cl, const float& angle, @@ -57,11 +45,9 @@ bool GEMRecHitStandardAlgo::compute(const GEMEtaPartition& roll, LocalPoint& Point, LocalError& error) const { - // Glob Pos and angle not used so far... if (globPos.z()<0){ } // Fake use to avoid warnings if (angle<0.){ } // Fake use to avoid warnings this->compute(roll,cl,Point,error); return true; } - diff --git a/RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.h similarity index 55% rename from RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h rename to RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.h index f24ffb96a09d9..5653b0a9c75ee 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h +++ b/RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.h @@ -1,16 +1,12 @@ -#ifndef RecoLocalMuon_GEMRecHitStandardAlgo_H -#define RecoLocalMuon_GEMRecHitStandardAlgo_H - +#ifndef RecoLocalMuon_GEMRecHit_GEMRecHitStandardAlgo_H +#define RecoLocalMuon_GEMRecHit_GEMRecHitStandardAlgo_H /** \class GEMRecHitStandardAlgo * Concrete implementation of GEMRecHitBaseAlgo. * * \author M. Maggi -- INFN Bari */ - #include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h" - - class GEMRecHitStandardAlgo : public GEMRecHitBaseAlgo { public: /// Constructor @@ -24,19 +20,17 @@ class GEMRecHitStandardAlgo : public GEMRecHitBaseAlgo { /// Pass the Event Setup to the algo at each event void setES(const edm::EventSetup& setup) override; - bool compute(const GEMEtaPartition& roll, - const GEMCluster& cluster, - LocalPoint& point, - LocalError& error) const override; - + const GEMCluster& cluster, + LocalPoint& point, + LocalError& error) const override; bool compute(const GEMEtaPartition& roll, - const GEMCluster& cluster, - const float& angle, - const GlobalPoint& globPos, - LocalPoint& point, - LocalError& error) const override; + const GEMCluster& cluster, + const float& angle, + const GlobalPoint& globPos, + LocalPoint& point, + LocalError& error) const override; }; #endif diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.cc similarity index 96% rename from RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc rename to RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.cc index 709f741d29206..3f31535af9b25 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.cc +++ b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.cc @@ -5,7 +5,7 @@ * \author M. Maggi -- INFN Bari */ -#include "ME0RecHitProducer.h" +#include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h" ME0RecHitProducer::ME0RecHitProducer(const edm::ParameterSet& config): diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h similarity index 100% rename from RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h rename to RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.cc similarity index 93% rename from RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc rename to RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.cc index b73b193d72dc3..8beedb5383944 100644 --- a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.cc +++ b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.cc @@ -6,7 +6,7 @@ * \author M. Maggi -- INFN */ -#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h" +#include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" diff --git a/RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h b/RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.h similarity index 100% rename from RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h rename to RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.h diff --git a/RecoLocalMuon/GEMRecHit/src/SealModule.cc b/RecoLocalMuon/GEMRecHit/plugins/SealModule.cc similarity index 65% rename from RecoLocalMuon/GEMRecHit/src/SealModule.cc rename to RecoLocalMuon/GEMRecHit/plugins/SealModule.cc index 2c2cf0d4d20e8..869a80b0e26ba 100644 --- a/RecoLocalMuon/GEMRecHit/src/SealModule.cc +++ b/RecoLocalMuon/GEMRecHit/plugins/SealModule.cc @@ -4,16 +4,15 @@ #include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h" #include "RecoLocalMuon/GEMRecHit/interface/ME0RecHitAlgoFactory.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.h" +#include "RecoLocalMuon/GEMRecHit/plugins/GEMRecHitProducer.h" DEFINE_FWK_MODULE(GEMRecHitProducer); -#include "RecoLocalMuon/GEMRecHit/src/GEMRecHitStandardAlgo.h" +#include "RecoLocalMuon/GEMRecHit/plugins/GEMRecHitStandardAlgo.h" DEFINE_EDM_PLUGIN (GEMRecHitAlgoFactory, GEMRecHitStandardAlgo, "GEMRecHitStandardAlgo"); - -#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitProducer.h" +#include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitProducer.h" DEFINE_FWK_MODULE(ME0RecHitProducer); -#include "RecoLocalMuon/GEMRecHit/src/ME0RecHitStandardAlgo.h" +#include "RecoLocalMuon/GEMRecHit/plugins/ME0RecHitStandardAlgo.h" DEFINE_EDM_PLUGIN (ME0RecHitAlgoFactory, ME0RecHitStandardAlgo, "ME0RecHitStandardAlgo"); diff --git a/RecoLocalMuon/GEMRecHit/python/gemRecHits_cfi.py b/RecoLocalMuon/GEMRecHit/python/gemRecHits_cfi.py index e7ebb09eb251b..6bec212f342e0 100644 --- a/RecoLocalMuon/GEMRecHit/python/gemRecHits_cfi.py +++ b/RecoLocalMuon/GEMRecHit/python/gemRecHits_cfi.py @@ -1,11 +1,11 @@ import FWCore.ParameterSet.Config as cms -gemRecHits = cms.EDProducer("GEMRecHitProducer", - recAlgoConfig = cms.PSet(), - recAlgo = cms.string('GEMRecHitStandardAlgo'), - gemDigiLabel = cms.InputTag("muonGEMDigis"), - #maskSource = cms.string('File'), - #maskvecfile = cms.FileInPath('RecoLocalMuon/GEMRecHit/data/GEMMaskVec.dat'), - #deadSource = cms.string('File'), - #deadvecfile = cms.FileInPath('RecoLocalMuon/GEMRecHit/data/GEMDeadVec.dat') -) +# masking is off by default - turn on with 'applyMasking' +# default masking uses DB, to use txt file, set maskFile or deadFile to the relative path of file + +from RecoLocalMuon.GEMRecHit.gemRecHitsDef_cfi import * +gemRecHits = gemRecHitsDef.clone( + #applyMasking = False, + #maskFile = cms.FileInPath("RecoLocalMuon/GEMRecHit/data/maskedStrips.txt"), + #deadFile = cms.FileInPath("RecoLocalMuon/GEMRecHit/data/deadStrips.txt") + ) diff --git a/RecoLocalMuon/GEMRecHit/src/GEMCluster.cc b/RecoLocalMuon/GEMRecHit/src/GEMCluster.cc index 1fece1dfd9825..8191c1123e61c 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMCluster.cc +++ b/RecoLocalMuon/GEMRecHit/src/GEMCluster.cc @@ -1,4 +1,4 @@ -#include "GEMCluster.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMCluster.h" #include #include diff --git a/RecoLocalMuon/GEMRecHit/src/GEMClusterContainer.h b/RecoLocalMuon/GEMRecHit/src/GEMClusterContainer.h deleted file mode 100644 index 76b7d2adf2ff0..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/GEMClusterContainer.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef RecoLocalMuon_GEMClusterContainer_h -#define RecoLocalMuon_GEMClusterContainer_h -#include -class GEMCluster; -typedef std::set GEMClusterContainer; -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.cc b/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.cc index 0a1d25b2397de..ba7f7f59daf55 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.cc +++ b/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.cc @@ -1,72 +1,37 @@ -#include "GEMClusterizer.h" -#include "GEMCluster.h" -#include "GEMClusterContainer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h" - -GEMClusterizer::GEMClusterizer() -{ -} - -GEMClusterizer::~GEMClusterizer() +GEMClusterContainer GEMClusterizer::doAction(const GEMDigiCollection::Range& digiRange) { -} - -GEMClusterContainer -GEMClusterizer::doAction(const GEMDigiCollection::Range& digiRange){ - GEMClusterContainer cls; - for (GEMDigiCollection::const_iterator digi = digiRange.first; - digi != digiRange.second; - digi++) { - GEMCluster cl(digi->strip(),digi->strip(),digi->bx()); - cls.insert(cl); + GEMClusterContainer initialCluster, finalCluster; + // Return empty container for null input + if ( std::distance(digiRange.second, digiRange.first) == 0 ) return finalCluster; + + // Start from single digi recHits + for ( auto digi = digiRange.first; digi != digiRange.second; ++digi ) { + GEMCluster cl(digi->strip(), digi->strip(), digi->bx()); + initialCluster.insert(cl); } - GEMClusterContainer clsNew =this->doActualAction(cls); - return clsNew; -} + if ( initialCluster.empty() ) return finalCluster; // Confirm the collection is valid -GEMClusterContainer -GEMClusterizer::doActualAction(GEMClusterContainer& initialclusters){ - - GEMClusterContainer finalCluster; - GEMCluster prev; + // Start from the first initial cluster + GEMCluster prev = *initialCluster.begin(); - unsigned int j = 0; - for(GEMClusterContainer::const_iterator i=initialclusters.begin(); - i != initialclusters.end(); i++){ - GEMCluster cl = *i; - - if(i==initialclusters.begin()){ - prev = cl; - j++; - if(j == initialclusters.size()){ - finalCluster.insert(prev); - } - else if(j < initialclusters.size()){ - continue; - } - } - - if(prev.isAdjacent(cl)) { - prev.merge(cl); - j++; - if(j == initialclusters.size()){ - finalCluster.insert(prev); - } + // Loop over the remaining digis + // Note that the last one remains as open in this loop + for ( auto cl = std::next(initialCluster.begin()); cl != initialCluster.end(); ++cl ) { + if ( prev.isAdjacent(*cl) ) { + // Merged digi to the previous one + prev.merge(*cl); } else { - j++; - if(j < initialclusters.size()){ - finalCluster.insert(prev); - prev = cl; - } - if(j == initialclusters.size()){ - finalCluster.insert(prev); - finalCluster.insert(cl); - } + // Close the previous cluster and start new cluster + finalCluster.insert(prev); + prev = *cl; } } + // Finalize by adding the last cluster + finalCluster.insert(prev); + return finalCluster; -} - - +} diff --git a/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.h b/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.h deleted file mode 100644 index 70e2cc38277a2..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/GEMClusterizer.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RecoLocalMuon_GEMClusterizer_h -#define RecoLocalMuon_GEMClusterizer_h -/** \class GEMClusterizer - * \author M. Maggi -- INFN Bari - */ - -#include "GEMClusterContainer.h" -#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" - -class GEMCluster; -class GEMClusterizer{ - public: - GEMClusterizer(); - ~GEMClusterizer(); - GEMClusterContainer doAction(const GEMDigiCollection::Range& digiRange); - - private: - GEMClusterContainer doActualAction(GEMClusterContainer& initialclusters); - - private: - GEMClusterContainer cls; -}; -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.cc b/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.cc index 98e7333000e7e..cd2cf2e4d9c16 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.cc +++ b/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.cc @@ -1,87 +1,40 @@ - /** \Class GEMMaskReClusterizer * \author J.C. Sanabria -- UniAndes, Bogota */ - -#include "GEMMaskReClusterizer.h" - - - -GEMMaskReClusterizer::GEMMaskReClusterizer() -{ - -} - - -GEMMaskReClusterizer::~GEMMaskReClusterizer() -{ - -} - +#include "RecoLocalMuon/GEMRecHit/interface/GEMCluster.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h" GEMClusterContainer GEMMaskReClusterizer::doAction(const GEMDetId& id, - GEMClusterContainer& initClusters, - const EtaPartitionMask& mask) + GEMClusterContainer& initClusters, + const EtaPartitionMask& mask) const { - GEMClusterContainer finClusters; - GEMCluster prev; - - unsigned int j = 0; - - - for (GEMClusterContainer::const_iterator i = initClusters.begin(); i != initClusters.end(); i++ ) { - - GEMCluster cl = *i; - - if ( i == initClusters.begin() ) { - prev = cl; - j++; - if ( j == initClusters.size() ) { - finClusters.insert(prev); - } - else if ( j < initClusters.size() ) { - continue; - } - } - - - if ( ((prev.firstStrip()-cl.lastStrip()) == 2 && this->get(mask,(cl.lastStrip()+1))) - && (cl.bx() == prev.bx()) ) { - - GEMCluster merged(cl.firstStrip(),prev.lastStrip(),cl.bx()); - prev = merged; - j++; - if ( j == initClusters.size() ) { - finClusters.insert(prev); - } + if ( initClusters.empty() ) return finClusters; + + GEMCluster prev = *initClusters.begin(); + for ( auto cl = std::next(initClusters.begin()); cl != initClusters.end(); ++cl ) { + // Merge this cluster if it is adjacent by 1 masked strip + // Note that the GEMClusterContainer collection is sorted in DECREASING ORDER of strip # + // So the prev. cluster is placed after the current cluster (check the < operator of GEMCluster carefully) + if ( (prev.firstStrip()-cl->lastStrip()) == 2 and + this->get(mask, cl->lastStrip()+1) and prev.bx() == cl->bx() ) { + prev = GEMCluster(cl->firstStrip(), prev.lastStrip(), cl->bx()); } - else { - - j++; - if ( j < initClusters.size() ) { - finClusters.insert(prev); - prev = cl; - } - if ( j == initClusters.size() ) { - finClusters.insert(prev); - finClusters.insert(cl); - } + finClusters.insert(prev); + prev = *cl; } - } + // Finalize by putting the last cluster to the collection + finClusters.insert(prev); + return finClusters; } - - -int GEMMaskReClusterizer::get(const EtaPartitionMask& mask, int strip) +bool GEMMaskReClusterizer::get(const EtaPartitionMask& mask, int strip) const { - - if ( mask.test(strip-1) ) return 1; - else return 0; - + return mask.test(strip-1); } diff --git a/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.h b/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.h deleted file mode 100644 index 6138f066f1c91..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef RecoLocalMuon_GEMMaskReClusterizer_h -#define RecoLocalMuon_GEMMaskReClusterizer_h - -/** \Class GEMMaskReClusterizer - * \author J.C. Sanabria -- UniAndes, Bogota - */ - -#include "GEMEtaPartitionMask.h" - -#include "GEMCluster.h" -#include "GEMClusterizer.h" -#include "GEMClusterContainer.h" - -#include "DataFormats/MuonDetId/interface/GEMDetId.h" - - -class GEMMaskReClusterizer -{ - public : - - GEMMaskReClusterizer(); - ~GEMMaskReClusterizer(); - GEMClusterContainer doAction(const GEMDetId& ,GEMClusterContainer& , const EtaPartitionMask& ); - int get(const EtaPartitionMask& ,int ); - -}; - -#endif diff --git a/RecoLocalMuon/GEMRecHit/src/GEMRecHitBaseAlgo.cc b/RecoLocalMuon/GEMRecHit/src/GEMRecHitBaseAlgo.cc index 8d310992b2a24..07773005d9896 100644 --- a/RecoLocalMuon/GEMRecHit/src/GEMRecHitBaseAlgo.cc +++ b/RecoLocalMuon/GEMRecHit/src/GEMRecHitBaseAlgo.cc @@ -3,28 +3,18 @@ * * \author M. Maggi -- INFN Bari */ - - - #include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMClusterContainer.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMCluster.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMClusterizer.h" -#include "RecoLocalMuon/GEMRecHit/src/GEMMaskReClusterizer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMClusterizer.h" +#include "RecoLocalMuon/GEMRecHit/interface/GEMMaskReClusterizer.h" #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - -GEMRecHitBaseAlgo::GEMRecHitBaseAlgo(const edm::ParameterSet& config) { - // theSync = GEMTTrigSyncFactory::get()->create(config.getParameter("tTrigMode"), - //config.getParameter("tTrigModeConfig")); -} +GEMRecHitBaseAlgo::GEMRecHitBaseAlgo(const edm::ParameterSet& config) {} GEMRecHitBaseAlgo::~GEMRecHitBaseAlgo(){} - // Build all hits in the range associated to the layerId, at the 1st step. edm::OwnVector GEMRecHitBaseAlgo::reconstruct(const GEMEtaPartition& roll, const GEMDetId& gemId, @@ -32,15 +22,13 @@ edm::OwnVector GEMRecHitBaseAlgo::reconstruct(const GEMEtaPartition& const EtaPartitionMask& mask) { edm::OwnVector result; - GEMClusterizer clizer; GEMClusterContainer tcls = clizer.doAction(digiRange); GEMMaskReClusterizer mrclizer; GEMClusterContainer cls = mrclizer.doAction(gemId,tcls,mask); - for (GEMClusterContainer::const_iterator cl = cls.begin(); - cl != cls.end(); cl++){ + cl != cls.end(); cl++) { LocalError tmpErr; LocalPoint point; @@ -53,7 +41,6 @@ edm::OwnVector GEMRecHitBaseAlgo::reconstruct(const GEMEtaPartition& int clusterSize=cl->clusterSize(); GEMRecHit* recHit = new GEMRecHit(gemId,cl->bx(),firstClustStrip,clusterSize,point,tmpErr); - result.push_back(recHit); } return result; diff --git a/RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.cc b/RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.cc deleted file mode 100644 index b6877cc1ef5f1..0000000000000 --- a/RecoLocalMuon/GEMRecHit/src/GEMRecHitProducer.cc +++ /dev/null @@ -1,207 +0,0 @@ -/** \file - * - * \author M. Maggi -- INFN Bari -*/ - -#include "GEMRecHitProducer.h" - - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h" - -#include "Geometry/GEMGeometry/interface/GEMEtaPartition.h" -#include "Geometry/GEMGeometry/interface/GEMGeometry.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHit.h" - -#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitBaseAlgo.h" -#include "RecoLocalMuon/GEMRecHit/interface/GEMRecHitAlgoFactory.h" -#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h" - -// #include "CondFormats/GEMObjects/interface/GEMMaskedStrips.h" -// #include "CondFormats/DataRecord/interface/GEMMaskedStripsRcd.h" -// #include "CondFormats/GEMObjects/interface/GEMDeadStrips.h" -// #include "CondFormats/DataRecord/interface/GEMDeadStripsRcd.h" - -#include - - -using namespace edm; -using namespace std; - - -GEMRecHitProducer::GEMRecHitProducer(const ParameterSet& config): - // Get the concrete reconstruction algo from the factory - theAlgo{GEMRecHitAlgoFactory::get()->create(config.getParameter("recAlgo"), - config.getParameter("recAlgoConfig"))} -{ - - - // Set verbose output - - produces(); - - theGEMDigiToken = consumes(config.getParameter("gemDigiLabel")); - - // Get masked- and dead-strip information - - /* GEMMaskedStripsObj = new GEMMaskedStrips(); - - GEMDeadStripsObj = new GEMDeadStrips(); - - maskSource = config.getParameter("maskSource"); - - if (maskSource == "File") { - edm::FileInPath fp = config.getParameter("maskvecfile"); - std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in); - if ( !inputFile ) { - std::cerr << "Masked Strips File cannot not be opened" << std::endl; - exit(1); - } - while ( inputFile.good() ) { - GEMMaskedStrips::MaskItem Item; - inputFile >> Item.rawId >> Item.strip; - if ( inputFile.good() ) MaskVec.push_back(Item); - } - inputFile.close(); - } - - deadSource = config.getParameter("deadSource"); - - if (deadSource == "File") { - edm::FileInPath fp = config.getParameter("deadvecfile"); - std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in); - if ( !inputFile ) { - std::cerr << "Dead Strips File cannot not be opened" << std::endl; - exit(1); - } - while ( inputFile.good() ) { - GEMDeadStrips::DeadItem Item; - inputFile >> Item.rawId >> Item.strip; - if ( inputFile.good() ) DeadVec.push_back(Item); - } - inputFile.close(); - } - */ -} - - -GEMRecHitProducer::~GEMRecHitProducer() = default; - -void GEMRecHitProducer::beginRun(const edm::Run& r, const edm::EventSetup& setup){ - - // Getting the masked-strip information - /* - if ( maskSource == "EventSetup" ) { - edm::ESHandle readoutMaskedStrips; - setup.get().get(readoutMaskedStrips); - const GEMMaskedStrips* tmp_obj = readoutMaskedStrips.product(); - GEMMaskedStripsObj->MaskVec = tmp_obj->MaskVec; - delete tmp_obj; - } - else if ( maskSource == "File" ) { - std::vector::iterator posVec; - for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) { - GEMMaskedStrips::MaskItem Item; - Item.rawId = (*posVec).rawId; - Item.strip = (*posVec).strip; - GEMMaskedStripsObj->MaskVec.push_back(Item); - } - } - */ - // Getting the dead-strip information - /* - if ( deadSource == "EventSetup" ) { - edm::ESHandle readoutDeadStrips; - setup.get().get(readoutDeadStrips); - const GEMDeadStrips* tmp_obj = readoutDeadStrips.product(); - GEMDeadStripsObj->DeadVec = tmp_obj->DeadVec; - delete tmp_obj; - } - else if ( deadSource == "File" ) { - std::vector::iterator posVec; - for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) { - GEMDeadStrips::DeadItem Item; - Item.rawId = (*posVec).rawId; - Item.strip = (*posVec).strip; - GEMDeadStripsObj->DeadVec.push_back(Item); - } - } - */ -} - - - -void GEMRecHitProducer::produce(Event& event, const EventSetup& setup) { - - // Get the GEM Geometry - - ESHandle gemGeom; - setup.get().get(gemGeom); - - // Get the digis from the event - - Handle digis; - event.getByToken(theGEMDigiToken,digis); - - // Pass the EventSetup to the algo - - theAlgo->setES(setup); - - // Create the pointer to the collection which will store the rechits - - auto recHitCollection = std::make_unique(); - - // Iterate through all digi collections ordered by LayerId - - GEMDigiCollection::DigiRangeIterator gemdgIt; - for (gemdgIt = digis->begin(); gemdgIt != digis->end(); - ++gemdgIt){ - - // The layerId - const GEMDetId& gemId = (*gemdgIt).first; - - // Get the GeomDet from the setup - const GEMEtaPartition* roll = gemGeom->etaPartition(gemId); - - // Get the iterators over the digis associated with this LayerId - const GEMDigiCollection::Range& range = (*gemdgIt).second; - - - // Getting the roll mask, that includes dead strips, for the given GEMDet - EtaPartitionMask mask; - /* - int rawId = gemId.rawId(); - int Size = GEMMaskedStripsObj->MaskVec.size(); - for (int i = 0; i < Size; i++ ) { - if ( GEMMaskedStripsObj->MaskVec[i].rawId == rawId ) { - int bit = GEMMaskedStripsObj->MaskVec[i].strip; - mask.set(bit-1); - } - } - - Size = GEMDeadStripsObj->DeadVec.size(); - for (int i = 0; i < Size; i++ ) { - if ( GEMDeadStripsObj->DeadVec[i].rawId == rawId ) { - int bit = GEMDeadStripsObj->DeadVec[i].strip; - mask.set(bit-1); - } - } - */ - // Call the reconstruction algorithm - - OwnVector recHits = - theAlgo->reconstruct(*roll, gemId, range, mask); - - if(!recHits.empty()) //FIXME: is it really needed? - recHitCollection->put(gemId, recHits.begin(), recHits.end()); - } - - event.put(std::move(recHitCollection)); - -} - diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index 35aa6b38f3d18..04db502ca89d7 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -508,6 +508,12 @@ void PixelCPEClusterRepair::checkRecommend2D( DetParam const & theDetParam, Clus } // The 1d pixel template SiPixelTemplate templ(thePixelTemp_); + if(!templ.interpolate(ID, theClusterParam.cotalpha, theClusterParam.cotbeta, theDetParam.bz, theDetParam.bx)){ + //error setting up template, return false + theClusterParam.recommended2D_ = false; + return; + } + //length of the cluster taking into account double sized pixels float nypix = clusterPayload.mcol; diff --git a/RecoParticleFlow/Configuration/test/BlockAnalyzer.cc b/RecoParticleFlow/Configuration/test/BlockAnalyzer.cc index 2e218139691cf..19e9859f1a650 100644 --- a/RecoParticleFlow/Configuration/test/BlockAnalyzer.cc +++ b/RecoParticleFlow/Configuration/test/BlockAnalyzer.cc @@ -39,7 +39,6 @@ #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" #include "DataFormats/Common/interface/ValueMap.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" diff --git a/RecoParticleFlow/PFClusterShapeProducer/BuildFile.xml b/RecoParticleFlow/PFClusterShapeProducer/BuildFile.xml deleted file mode 100644 index 0438227c3034b..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/BuildFile.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/RecoParticleFlow/PFClusterShapeProducer/interface/PFClusterShapeAlgo.h b/RecoParticleFlow/PFClusterShapeProducer/interface/PFClusterShapeAlgo.h deleted file mode 100644 index 7efdabc281078..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/interface/PFClusterShapeAlgo.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef _RecoParticleFlow_PFClusterShapeProducer_PFClusterShapeAlgo_h_ -#define _RecoParticleFlow_PFClusterShapeProducer_PFClusterShapeAlgo_h_ - -#include -#include - -#include "DataFormats/Math/interface/Point3D.h" - -#include "DataFormats/EgammaReco/interface/ClusterShape.h" -#include "DataFormats/EgammaReco/interface/ClusterShapeFwd.h" - -#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" -#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h" -#include "DataFormats/ParticleFlowReco/interface/PFClusterShapeAssociation.h" - -// Colin: corrected include for compiling in 1_7_X -// #include "FWCore/Framework/interface/Handle.h" -#include "DataFormats/Common/interface/Handle.h" - -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" -#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" - -#include "RecoCaloTools/Navigation/interface/CaloNavigator.h" - - -struct RecHitWithFraction -{ - DetId detId; - double energy; - math::XYZVector position; -}; - -class PFClusterShapeAlgo -{ - typedef std::map RecHitMap; - - enum Direction { N, NE, E, SE, S, SW, W, NW }; - enum GeomTopoIndex { BARREL = 0, ENDCAP = 1 }; - - public: - - explicit PFClusterShapeAlgo(bool useFractions, double w0); - - ~PFClusterShapeAlgo(); - - reco::ClusterShapeCollection * makeClusterShapes(edm::Handle clusterHandle, - edm::Handle rechitHandle, - const CaloSubdetectorGeometry * barrelGeo_p, - const CaloSubdetectorTopology * barrelTop_p, - const CaloSubdetectorGeometry * endcapGeo_p, - const CaloSubdetectorTopology * endcapTop_p); - - - private: - - bool useFractions_; - double w0_; - - unsigned int currentClusterIndex_; - reco::PFClusterRef currentCluster_p; - edm::Handle currentRecHit_v_p; - - unsigned int topoIndex; - std::vector topoVector; - unsigned int geomIndex; - std::vector geomVector; - - RecHitWithFraction map5x5[5][5]; - math::XYZVector meanPosition_; - double totalE_; - - Direction eMaxDir; // the direction of the highest-energy 2x2 subcluster - - DetId eMaxId_, e2ndId_; - double eMax_, e2nd_; - double e2x2_, e3x3_, e4x4_, e5x5_, e2x5Right_, e2x5Left_, e2x5Top_, e2x5Bottom_, e3x2_, e3x2Ratio_; - double covEtaEta_, covEtaPhi_, covPhiPhi_; - - reco::ClusterShape makeClusterShape(); - - int findPFRHIndexFromDetId(unsigned int id); - const reco::PFRecHitFraction * getFractionFromDetId(const DetId & id); - - void fill5x5Map(); - - void find_eMax_e2nd(); - - double addMapEnergies(int etaIndexLow, int etaIndexHigh, int phiIndexLow, int phiIndexHigh); - - void find_e2x2(); - void find_e3x2(); - void find_e3x3(); - void find_e4x4(); - void find_e5x5(); - - void find_e2x5Right(); // "Right" == "North" == greater Phi == greater navigator offset - void find_e2x5Left(); - void find_e2x5Top(); // "Top" == "East" == lesser Eta == lesser navigator offset - void find_e2x5Bottom(); - - void covariances(); -}; - -#endif diff --git a/RecoParticleFlow/PFClusterShapeProducer/plugins/BuildFile.xml b/RecoParticleFlow/PFClusterShapeProducer/plugins/BuildFile.xml deleted file mode 100644 index bc16736f9a55e..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/plugins/BuildFile.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterShapeProducer/plugins/PFClusterShapeProducer.cc b/RecoParticleFlow/PFClusterShapeProducer/plugins/PFClusterShapeProducer.cc deleted file mode 100644 index d5492aefd5c7a..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/plugins/PFClusterShapeProducer.cc +++ /dev/null @@ -1,108 +0,0 @@ -#include "RecoParticleFlow/PFClusterShapeProducer/plugins/PFClusterShapeProducer.h" - -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include "Geometry/Records/interface/CaloGeometryRecord.h" - -#include - -using namespace edm; -using namespace std; - -PFClusterShapeProducer::PFClusterShapeProducer(const edm::ParameterSet & ps) -{ - shapesLabel_ = ps.getParameter("PFClusterShapesLabel"); - - inputTagPFClustersECAL_ - = ps.getParameter("PFClustersECAL"); - inputTagPFRecHitsECAL_ - = ps.getParameter("PFRecHitsECAL"); - - csAlgo_p = new PFClusterShapeAlgo(ps.getParameter("useFractions"), - ps.getParameter("W0")); - - produces(shapesLabel_); - produces(shapesLabel_); -} - - -PFClusterShapeProducer::~PFClusterShapeProducer() -{ - delete csAlgo_p; -} - - -void PFClusterShapeProducer::produce(edm::Event & evt, const edm::EventSetup & es) -{ - - edm::Handle - clusterHandle = getClusterCollection(evt); - edm::Handle - rechitHandle = getRecHitCollection(evt); - - edm::ESHandle geoHandle; - es.get().get(geoHandle); - - const CaloSubdetectorGeometry * barrelGeo_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - const CaloSubdetectorTopology * barrelTop_p = new EcalBarrelTopology(geoHandle); - const CaloSubdetectorGeometry * endcapGeo_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - const CaloSubdetectorTopology * endcapTop_p = new EcalEndcapTopology(geoHandle); - - std::unique_ptr - csCollection_ap(csAlgo_p->makeClusterShapes(clusterHandle, rechitHandle, - barrelGeo_p, barrelTop_p, - endcapGeo_p, endcapTop_p)); - - edm::OrphanHandle shape_h = evt.put(std::move(csCollection_ap), shapesLabel_); - - auto association_ap = std::make_unique(); - - for (unsigned int i = 0; i < clusterHandle->size(); i++){ - association_ap->insert(edm::Ref(clusterHandle, i), - edm::Ref(shape_h, i)); - } - - evt.put(std::move(association_ap), shapesLabel_); - - delete barrelTop_p; - delete endcapTop_p; -} - - -edm::Handle -PFClusterShapeProducer::getClusterCollection(edm::Event & evt) -{ - edm::Handle handle; - - bool found = evt.getByLabel(inputTagPFClustersECAL_, handle); - if (!found) { - ostringstream err; - err<<"cannot find clusters: "< -PFClusterShapeProducer::getRecHitCollection(edm::Event & evt) -{ - edm::Handle handle; - - bool found = evt.getByLabel(inputTagPFRecHitsECAL_, handle); - if (!found) { - ostringstream err; - err<<"cannot find rechits: "< -#include - -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" - -#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" - -#include "DataFormats/EgammaReco/interface/ClusterShape.h" -#include "DataFormats/EgammaReco/interface/ClusterShapeFwd.h" - -#include "RecoParticleFlow/PFClusterShapeProducer/interface/PFClusterShapeAlgo.h" - -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" -#include "Geometry/CaloTopology/interface/EcalBarrelTopology.h" -#include "Geometry/CaloTopology/interface/EcalEndcapTopology.h" - - -class PFClusterShapeProducer : public edm::EDProducer -{ - public: - - explicit PFClusterShapeProducer(const edm::ParameterSet &); - - ~PFClusterShapeProducer() override; - - void produce(edm::Event & ev, const edm::EventSetup & es) override; - - private: - - std::string shapesLabel_; - - edm::InputTag inputTagPFClustersECAL_; - edm::InputTag inputTagPFRecHitsECAL_; - - PFClusterShapeAlgo * csAlgo_p; - - edm::Handle - getClusterCollection(edm::Event & evt); - - edm::Handle - getRecHitCollection(edm::Event & evt); -}; - -#endif diff --git a/RecoParticleFlow/PFClusterShapeProducer/plugins/SealModule.cc b/RecoParticleFlow/PFClusterShapeProducer/plugins/SealModule.cc deleted file mode 100644 index ef584abb237de..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/plugins/SealModule.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "RecoParticleFlow/PFClusterShapeProducer/plugins/PFClusterShapeProducer.h" - -DEFINE_FWK_MODULE(PFClusterShapeProducer); diff --git a/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapesSequence_cff.py b/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapesSequence_cff.py deleted file mode 100644 index 4489a78e6aa1f..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapesSequence_cff.py +++ /dev/null @@ -1,5 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from RecoParticleFlow.PFClusterShapeProducer.pfClusterShapes_cfi import * -pfClusterShapesSequence = cms.Sequence(pfClusterShapes) - diff --git a/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapes_cfi.py b/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapes_cfi.py deleted file mode 100644 index e777feddee0b4..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/python/pfClusterShapes_cfi.py +++ /dev/null @@ -1,11 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -pfClusterShapes = cms.EDProducer("PFClusterShapeProducer", - PFClusterShapesLabel = cms.string('ECAL'), - PFClustersECAL = cms.InputTag("particleFlowCluster","ECAL"), - PFRecHitsECAL = cms.InputTag("particleFlowCluster","ECAL"), - useFractions = cms.bool(False), - W0 = cms.double(4.2) -) - - diff --git a/RecoParticleFlow/PFClusterShapeProducer/src/PFClusterShapeAlgo.cc b/RecoParticleFlow/PFClusterShapeProducer/src/PFClusterShapeAlgo.cc deleted file mode 100644 index bddd996497a77..0000000000000 --- a/RecoParticleFlow/PFClusterShapeProducer/src/PFClusterShapeAlgo.cc +++ /dev/null @@ -1,333 +0,0 @@ -#include "RecoParticleFlow/PFClusterShapeProducer/interface/PFClusterShapeAlgo.h" - -PFClusterShapeAlgo::PFClusterShapeAlgo(bool useFractions, double w0) -{ - useFractions_ = useFractions; - w0_ = w0; -} - -PFClusterShapeAlgo::~PFClusterShapeAlgo() -{ -} - -reco::ClusterShapeCollection * -PFClusterShapeAlgo::makeClusterShapes(edm::Handle clusterHandle, - edm::Handle rechitHandle, - const CaloSubdetectorGeometry * the_barrelGeo_p, - const CaloSubdetectorTopology * the_barrelTop_p, - const CaloSubdetectorGeometry * the_endcapGeo_p, - const CaloSubdetectorTopology * the_endcapTop_p) -{ - static const float etaEndOfBarrel = 1.497; - - topoVector.push_back(the_barrelTop_p); - topoVector.push_back(the_endcapTop_p); - geomVector.push_back(the_barrelGeo_p); - geomVector.push_back(the_endcapGeo_p); - - reco::ClusterShapeCollection * shape_v_p = new reco::ClusterShapeCollection(); - - currentRecHit_v_p = rechitHandle; - - for (unsigned int i = 0; i < clusterHandle->size(); ++i) - { - // Make each cluster the "current" cluster - currentCluster_p = reco::PFClusterRef(clusterHandle, i); - currentClusterIndex_ = i; - - // Find the right topology to use with this cluster - topoIndex = BARREL; - geomIndex = BARREL; - const math::XYZVector currentClusterPos(currentCluster_p->position()); - if (fabs(currentClusterPos.eta()) > etaEndOfBarrel) - { - topoIndex = ENDCAP; - geomIndex = ENDCAP; - } - - // Create the clustershape and push it into the vector - shape_v_p->push_back(makeClusterShape()); - } - - topoVector.clear(); - topoVector.clear(); - geomVector.clear(); - geomVector.clear(); - - return shape_v_p; -} - -reco::ClusterShape PFClusterShapeAlgo::makeClusterShape() -{ - find_eMax_e2nd(); - fill5x5Map(); - - find_e2x2(); - find_e3x2(); - find_e3x3(); - find_e4x4(); - find_e5x5(); - - find_e2x5Right(); - find_e2x5Left(); - find_e2x5Top(); - find_e2x5Bottom(); - - covariances(); - - double dummyLAT = 0; - double dummyEtaLAT = 0; - double dummyPhiLAT = 0; - double dummyA20 = 0; - double dummyA42 = 0; - - std::vector dummyEnergyBasketFractionEta_v; - std::vector dummyEnergyBasketFractionPhi_v; - - return reco::ClusterShape(covEtaEta_, covEtaPhi_, covPhiPhi_, - eMax_, eMaxId_, e2nd_, e2ndId_, - e2x2_, e3x2_, e3x3_, e4x4_, e5x5_, - e2x5Right_, e2x5Left_, e2x5Top_, e2x5Bottom_, e3x2Ratio_, - dummyLAT, dummyEtaLAT, dummyPhiLAT, dummyA20, dummyA42, - dummyEnergyBasketFractionEta_v, dummyEnergyBasketFractionPhi_v); -} - - -void PFClusterShapeAlgo::find_eMax_e2nd() -{ - std::map energyMap; - - // First get the RecHitFractions: - const std::vector & fraction_v = currentCluster_p->recHitFractions(); - // For every one of them... - for (std::vector::const_iterator it = fraction_v.begin(); it != fraction_v.end(); ++it) - { - // ...find the corresponding rechit: - // const reco::PFRecHit & rechit = (*currentRecHit_v_p)[it->recHitIndex()]; - const reco::PFRecHitRef rechit = it->recHitRef(); - // ...and DetId: - const DetId rechitDetId = DetId(rechit->detId()); - // Make the new Pair and put it in the map: - energyMap[rechit->energy()] = rechitDetId; - } - // maps are sorted in ascending order so get the last two elements: - std::map::reverse_iterator it = energyMap.rbegin(); - eMax_ = it->first; - eMaxId_ = it->second; - it++; - e2nd_ = it->first; - e2ndId_ = it->second; -} - -int PFClusterShapeAlgo::findPFRHIndexFromDetId(unsigned int id) -{ - int index = -1; // need some negative number - for (unsigned int k = 0; k < currentRecHit_v_p->size(); ++k) - { - if ((*currentRecHit_v_p)[k].detId() == id) - { - index = static_cast(k); - break; - } - } - return index; -} - - -const reco::PFRecHitFraction * PFClusterShapeAlgo::getFractionFromDetId(const DetId & id) -{ - const std::vector< reco::PFRecHitFraction > & fraction_v = currentCluster_p->recHitFractions(); - for (std::vector::const_iterator it = fraction_v.begin(); it != fraction_v.end(); ++it) - { - //const unsigned int rhIndex = it->recHitIndex(); - //reco::PFRecHitRef rh_p(currentRecHit_v_p, rhIndex); - const reco::PFRecHitRef rh_p = it->recHitRef(); - const DetId rhDetId = DetId(rh_p->detId()); - if (rhDetId == id) - { - return &(*it); - } - } - return nullptr; -} - - -void PFClusterShapeAlgo::fill5x5Map() -{ - // first get a navigator to the central element - CaloNavigator position = CaloNavigator(eMaxId_, topoVector[topoIndex]); - - meanPosition_ = math::XYZVector(0.0, 0.0, 0.0); - totalE_ = 0; - - for (int i = 0; i < 5; ++i) - { - for (int j = 0; j < 5; ++j) - { - position.home(); - position.offsetBy(i - 2, j - 2); - - RecHitWithFraction newEntry; - newEntry.detId = DetId(0); - newEntry.energy = 0.0; - newEntry.position = math::XYZVector(0, 0, 0); - - if (*position != DetId(0)) // if this is a valid detId... - { - // ...find the corresponding PFRecHit index - const int index = findPFRHIndexFromDetId((*position).rawId()); - - if (index >= 0) // if a PFRecHit exists for this detId - { - double fraction = 1.0; - if (useFractions_) // if the algorithm should use fractions - { - fraction = 0.0; - const reco::PFRecHitFraction * fraction_p = getFractionFromDetId(*position); - if (fraction_p) { fraction = fraction_p->fraction(); } - } - - const reco::PFRecHitRef rhRef(currentRecHit_v_p, index); - const math::XYZVector crystalPosition(rhRef->position()); - const double energyFraction = rhRef->energy() * fraction; - - newEntry.detId = *position; - newEntry.energy = energyFraction; - newEntry.position = crystalPosition; - - meanPosition_ = meanPosition_ + crystalPosition * energyFraction; - totalE_ += energyFraction; - } - } - map5x5[i][j] = newEntry; - } - } - meanPosition_ /= totalE_; -} - -double PFClusterShapeAlgo::addMapEnergies(int etaIndexLow, int etaIndexHigh, int phiIndexLow, int phiIndexHigh) -{ - const int etaLow = etaIndexLow + 2; - const int etaHigh = etaIndexHigh + 2; - const int phiLow = phiIndexLow + 2; - const int phiHigh = phiIndexHigh + 2; - - double energy = 0; - - for (int i = etaLow; i <= etaHigh; ++i) - { - for (int j = phiLow; j <= phiHigh; ++j) - { - energy += map5x5[i][j].energy; - } - } - return energy; -} - -void PFClusterShapeAlgo::find_e3x3() { e3x3_ = addMapEnergies(-1, +1, -1, +1); } -void PFClusterShapeAlgo::find_e5x5() { e5x5_ = addMapEnergies(-2, +2, -2, +2); } -void PFClusterShapeAlgo::find_e2x5Right() { e2x5Right_ = addMapEnergies(-2, +2, +1, +2); } -void PFClusterShapeAlgo::find_e2x5Left() { e2x5Left_ = addMapEnergies(-2, +2, -2, -1); } -void PFClusterShapeAlgo::find_e2x5Top() { e2x5Top_ = addMapEnergies(-2, -1, -2, +2); } -void PFClusterShapeAlgo::find_e2x5Bottom() { e2x5Bottom_ = addMapEnergies(+1, +2, -2, +2); } - -void PFClusterShapeAlgo::find_e4x4() -{ - if (eMaxDir == SE) { e4x4_ = addMapEnergies(-2, +1, -2, +1); return; } - if (eMaxDir == NE) { e4x4_ = addMapEnergies(-2, +1, -1, +2); return; } - if (eMaxDir == SW) { e4x4_ = addMapEnergies(-1, +2, -2, +1); return; } - if (eMaxDir == NW) { e4x4_ = addMapEnergies(-1, +2, -1, +2); return; } -} - -void PFClusterShapeAlgo::find_e2x2() -{ - std::map directionMap; - - directionMap[addMapEnergies(-1, +0, -1, +0)] = SE; - directionMap[addMapEnergies(-1, +0, +0, +1)] = NE; - directionMap[addMapEnergies(+0, +1, -1, +0)] = SW; - directionMap[addMapEnergies(+0, +1, +0, +1)] = NW; - - const std::map::reverse_iterator eMaxDir_it = directionMap.rbegin(); - - eMaxDir = eMaxDir_it->second; - - e2x2_ = eMaxDir_it->first; -} - -void PFClusterShapeAlgo::find_e3x2() -{ - // Find the direction of the highest energy neighbour - std::map directionMap; - directionMap[map5x5[2][3].energy] = N; - directionMap[map5x5[2][1].energy] = S; - directionMap[map5x5[1][2].energy] = E; - directionMap[map5x5[3][2].energy] = W; - // Maps are sorted in ascending order - get the last element - const Direction dir = directionMap.rbegin()->second; - - if (dir == N) - { - e3x2_ = addMapEnergies(-1, +1, +0, +1); - const double numerator = map5x5[3][2].energy + map5x5[1][2].energy; - const double denominator = map5x5[1][3].energy + map5x5[3][3].energy + 0.5; - e3x2Ratio_ = numerator / denominator; - } - else if (dir == S) - { - e3x2_ = addMapEnergies(-1, +1, -1, +0); - const double numerator = map5x5[3][2].energy + map5x5[1][2].energy; - const double denominator = map5x5[1][1].energy + map5x5[3][1].energy + 0.5; - e3x2Ratio_ = numerator / denominator; - } - else if (dir == W) - { - e3x2_ = addMapEnergies(+0, +1, -1, +1); - const double numerator = map5x5[2][3].energy + map5x5[2][1].energy; - const double denominator = map5x5[3][3].energy + map5x5[3][1].energy + 0.5; - e3x2Ratio_ = numerator / denominator; - } - else if (dir == E) - { - e3x2_ = addMapEnergies(-1, +0, -1, +1); - const double numerator = map5x5[2][3].energy + map5x5[2][1].energy; - const double denominator = map5x5[1][1].energy + map5x5[1][3].energy + 0.5; - e3x2Ratio_ = numerator / denominator; - } -} - -void PFClusterShapeAlgo::covariances() -{ - double numeratorEtaEta = 0; - double numeratorEtaPhi = 0; - double numeratorPhiPhi = 0; - double denominator = 0; - - for (int i = 0; i < 5; ++i) - { - for (int j = 0; j < 5; ++j) - { - const math::XYZVector & crystalPosition(map5x5[i][j].position); - - double dPhi = crystalPosition.phi() - meanPosition_.phi(); - if (dPhi > + Geom::pi()) { dPhi = Geom::twoPi() - dPhi; } - if (dPhi < - Geom::pi()) { dPhi = Geom::twoPi() - dPhi; } - - const double dEta = crystalPosition.eta() - meanPosition_.eta(); - - const double w = std::max(0.0, w0_ + log(map5x5[i][j].energy / totalE_)); - - denominator += w; - numeratorEtaEta += w * dEta * dEta; - numeratorEtaPhi += w * dEta * dPhi; - numeratorPhiPhi += w * dPhi * dPhi; - } - } - - covEtaEta_ = numeratorEtaEta / denominator; - covEtaPhi_ = numeratorEtaPhi / denominator; - covPhiPhi_ = numeratorPhiPhi / denominator; -} - - - diff --git a/RecoParticleFlow/PFClusterTools/data/ResolutionMap.root b/RecoParticleFlow/PFClusterTools/data/ResolutionMap.root deleted file mode 100644 index 733ea2365d646..0000000000000 Binary files a/RecoParticleFlow/PFClusterTools/data/ResolutionMap.root and /dev/null differ diff --git a/RecoParticleFlow/PFClusterTools/data/download.url b/RecoParticleFlow/PFClusterTools/data/download.url deleted file mode 100644 index c134b2844d326..0000000000000 --- a/RecoParticleFlow/PFClusterTools/data/download.url +++ /dev/null @@ -1,2 +0,0 @@ -http://cmsdoc.cern.ch/cms/data/CMSSW/RecoParticleFlow/PFClusterTools/data/ResolutionMap.root - diff --git a/RecoParticleFlow/PFClusterTools/doc/PFClusterTools.doc b/RecoParticleFlow/PFClusterTools/doc/PFClusterTools.doc deleted file mode 100644 index fc4d8c942fac3..0000000000000 --- a/RecoParticleFlow/PFClusterTools/doc/PFClusterTools.doc +++ /dev/null @@ -1,40 +0,0 @@ - -/*! - -\page RecoParticleFlow_PFClusterTools Package RecoParticleFlow/PFClusterTools - -
- - - -Source code (CVS tag: @CVS_TAG@) - -Administrative privileges - -
- -\section desc Description - - -(THE PACKAGE ADMINISTATOR SHOULD REPLACE THIS SENTENCE WITH HAND-WRITTEN DOCUMENTATION SAYING WHAT THE PACKAGE DOES.) - -\subsection interface Public interface - - - -\subsection modules Modules - - - -\subsection tests Unit tests and examples - -Unknown - -\section status Status and planned development - -Unknown - -
-Last updated: -@DATE@ Author: computer-generated. -*/ - diff --git a/RecoParticleFlow/PFClusterTools/interface/CalibCompare.h b/RecoParticleFlow/PFClusterTools/interface/CalibCompare.h deleted file mode 100644 index f64f81efe2f35..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/CalibCompare.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef CALIBCOMPARE_H_ -#define CALIBCOMPARE_H_ - -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" -#include "RecoParticleFlow/PFClusterTools/interface/SpaceManager.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h" -#include "RecoParticleFlow/PFClusterTools/interface/Erl_mlp.h" - -#include -#include -#include -#include -#include -#include - - -namespace pftools { -class IO; - -class CalibCompare { -public: - - CalibCompare(IO* options); - - virtual ~CalibCompare(); - - void calibrateCalibratables(TChain& sourceTree, - const std::string& exercisefile); - - - void setTarget(CalibrationTarget t) { - target_ = t; - } - - - void evaluateCalibrations(TTree& tree, pftools::Calibratable* calibrated, const std::vector& calibVec); - -private: - - CalibCompare(const CalibCompare&) = delete; - void operator=(const CalibCompare&) = delete; -// double lowE_, highE_, lowEta_, highEta_, lowPhi_, highPhi_; -// unsigned divE_, divEta_, divPhi_; - bool withOffset_; - CalibrationTarget target_; - IO* options_; - unsigned debug_; - - double mlpOffset_; - double mlpSlope_; - PFClusterCalibration clusterCalibration_; - Erl_mlp erlCalibration_; - -}; -} - -#endif /*CALIBCOMPARE_H_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/CalibratableTest.h b/RecoParticleFlow/PFClusterTools/interface/CalibratableTest.h deleted file mode 100644 index 2c4fd63fa0648..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/CalibratableTest.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef CALIBRATABLETEST_H_ -#define CALIBRATABLETEST_H_ - -// system include files -#include -#include -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFSimParticleFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" - -#include - - -/** - * \class CalibratableTest - * \brief EDAnalyzer to exercise and demonstrate usage of Calibratable tree - * \author Jamie Ballin, Imperial College London - * \date November 2008 - * - * OBJECTIVE: this analyzer will create a tree of PFClusterTools/Calibratable - * instances. Each entry of the tree represents particle flow information relating - * to one pion in a multi-pion event. The use of monte carlo is assumed as - * sim particle information is extracted too. - * - * USAGE: This is an analyzer, not a producer: the tree it produces is stored in a seperate - * ROOT file using the CMSSW TFileService. - * - * Consult test/CalibratableTest_FastSim.py for a sample CMSSW configuration. - * Run the example from that directory with, - * cmsRun CalibratableTest_FastSim.py - * This will produce a file with a tree inside. Browse the contents in bare root - * with a TBrowser. - * - * NOTE: This analyzer does not exercise the complete functionality of the Calibratable - * class. For instance, tracks and rechits are not stored. Contact me (the author) - * for more details, and for an analyzer that we use to extract particle information - * to calibrate the particle flow algorithm. A MUCH more involved example from my - * private analysis is to be found in, - * UserCode/JamieBallin/interface/DipionDelegate.h - * - * General details about the usage of Calibratable may be found at, - * https://twiki.cern.ch/twiki/bin/view/CMS/PFClusterToolsPackage - */ -class CalibratableTest : public edm::one::EDAnalyzer<> { -public: - explicit CalibratableTest(const edm::ParameterSet&); - ~CalibratableTest() override; - - /* - * Returns the collection in the event matching the Handle. - */ - template void getCollection(edm::Handle& c, - const edm::InputTag& tag, const edm::Event& event) const; - -private: - /* - * The usual EDAnalyzer methods - */ - void beginJob() override; - void analyze(const edm::Event&, const edm::EventSetup&) override; - void endJob() override; - - /* - * Called for each particle in the event to fill the tree and - * reset calib_. - */ - virtual void fillTreeAndReset(); - - /* - * Finds the main pions generated by FastSim - */ - std::vector findPrimarySimParticles( - const std::vector& sims); - - /* - * Finds PFCandidates within some deltaR of the supplied sim particle. - */ - std::vector findCandidatesInDeltaR(const reco::PFSimParticle& pft, - const std::vector& cands, const double& deltaR); - - /* - * Fills calib_ with PFCandidate information. - */ - void extractCandidate(const reco::PFCandidate& cand); - - /* - * Computes delta R between two objects. - */ - double deltaR(const double& eta1, const double& eta2, const double& phi1, - const double& phi2); - - //Calibratable tree - TTree* tree_; - - //This analyzer produces a file with a tree so we need, - edm::Service fileservice_; - - //Debug? - int debug_; - - //True if this event was generally successful: - //if no sim particles are found, this will be false - bool thisEventPasses_; - //True if this particle should be written to the tree - //If no PFCandidates are found within a delta R cone of the sim particle, - //this will be false. - bool thisParticlePasses_; - - //The Calibratable object - pftools::Calibratable* calib_; - - //Increment nWrites_ for every record written to the tree - //Incremement nFails_ for every event/particle not written to the tree (thisEventPasses_ == false) - unsigned nParticleWrites_, nParticleFails_; - unsigned nEventWrites_, nEventFails_; - - //Size of cone around sim particle to look for PFCandidates - double deltaRCandToSim_; - - //Collection input tags - edm::InputTag inputTagCandidates_; - edm::InputTag inputTagSimParticles_; - edm::InputTag inputTagClustersEcal_; - edm::InputTag inputTagClustersHcal_; - - //collections - edm::Handle* pfCandidates_; - edm::Handle* simParticles_; - edm::Handle* clustersEcal_; - edm::Handle* clustersHcal_; - -}; - -template void CalibratableTest::getCollection(edm::Handle& c, - const edm::InputTag& tag, const edm::Event& event) const { - - try { - event.getByLabel(tag, c); - if(!c.isValid()) { - std::cout << "Warning! Collection for label " << tag << " is not valid!" << std::endl; - } - } - catch (cms::Exception& err) { - std::cout << "Couldn't get collection\n"; - //std::ostringstream s; - //LogError("Error getting collection!") << s; - } -} - -#endif /*CALIBRATABLETEST_H_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Calibrator.h b/RecoParticleFlow/PFClusterTools/interface/Calibrator.h deleted file mode 100644 index 2afa2253973ee..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Calibrator.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef CALIBRATOR_HH_ -#define CALIBRATOR_HH_ - -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" - -#include -#include -#include - -namespace pftools { - -/** - \class Calibrator - \brief Abstract base class for Particle Flow calibration algorithms - - \author Jamie Ballin - \date April 2008 - */ -class Calibrator { -public: - - Calibrator(); - virtual ~Calibrator(); - - void addDetectorElement(DetectorElementPtr const de); - - void addParticleDeposit(ParticleDepositPtr pd); - - /* - * Returns the calibration coefficient for each detector element, using data - * from all particle depositions stored within. - */ - std::map getCalibrationCoefficients() noexcept(false) { - return getCalibrationCoefficientsCore(); - } - - /* - * Here we use the virtual constructor idea to allow for plug-and-play Calibrators - * See http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8 - */ - virtual Calibrator* clone() const = 0; - virtual Calibrator* create() const = 0; - - int hasParticles() const { - return myParticleDeposits.size(); - } - - std::vector getParticles() { - return myParticleDeposits; - } - - - -protected: - virtual std::map - getCalibrationCoefficientsCore() noexcept(false); - - std::vector myDetectorElements; - std::vector myParticleDeposits; -}; - -typedef boost::shared_ptr CalibratorPtr; - -} - -#endif /*CALIBRATOR_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Deposition.h b/RecoParticleFlow/PFClusterTools/interface/Deposition.h deleted file mode 100644 index 1cb51baa210f4..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Deposition.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef DEPOSITION_HH_ -#define DEPOSITION_HH_ -#include - -#include - -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" - -namespace pftools { - -/** - * \class Deposition - * - * \brief This class holds an arbitrary energy deposition, specified in terms of angular - * position, energy, depth (optional) and detector element type. - * - * \author Jamie Balin - * \date April 2008 - * */ -class Deposition { -public: - - inline void setEnergy(double energy) { - myEnergy = energy; - } - - - inline double getEta() const { - return myEta; - } - ; - - inline double getPhi() const { - return myPhi; - } - ; - - inline double getEnergy() const { - return myEnergy; - } - ; - - inline DetectorElementPtr getDetectorElement() const { - return myElementPtr; - } - ; - - /* - * Returns the user specified "depth" for this deposition. - * Usually presumed to be zero. - * */ - inline double getDepth() const { - return myDepth; - } - ; - - Deposition(DetectorElementPtr element, double eta = 0.0, double phi = 0.0, - double energy = 0.0, double depth = 0.0); - - virtual ~Deposition(); - -private: - //DetectorElement* myElement; - DetectorElementPtr myElementPtr; - - double myEta; - double myPhi; - double myEnergy; - double myDepth; -}; - -typedef boost::shared_ptr DepositionPtr; - -/* - * Streams a description of this deposition into the supplied stream. - * */ -std::ostream& operator<<(std::ostream& s, const Deposition& d); - -} - -#endif /*DEPOSITION_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/DetectorElement.h b/RecoParticleFlow/PFClusterTools/interface/DetectorElement.h deleted file mode 100644 index 8b91f19ed0393..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/DetectorElement.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef DETECTORELEMENT_HH_ -#define DETECTORELEMENT_HH_ - -#include -#include -/* - * This is a dirty macro that allows you to make vectors of DetectorElements within CINT - */ -//#ifdef __MAKECINT__ -//#pragma link C++ class std::vector -//#endif -// -//#ifdef __MAKECINT__ -//#pragma link C++ class std::vector -//#endif - -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" - -#include "TH2F.h" -#include "TH1F.h" -#include - -namespace pftools { - -/** - \class DetectorElement - \brief Represents an energy-measuring region of our detector. - - The Calibrator class will make a calibration constant for each DetectorElement passed to it. - - \author Jamie Ballin - \date April 2008 - */ -class DetectorElement { -public: - - DetectorElement(DetectorElementType type, double calib = 1.0); - - inline DetectorElementType getType() const { - return myType; - } - ; - - virtual ~DetectorElement(); - - /* - * Returns a global detector element calibration. - */ - double getCalib() const { - return getCalibCore(); - } - - /* - * Returns the calibration for this detector element as a function - * of eta and phi. - */ - double getCalib(double eta, double phi) const { - return getCalibCore(eta, phi); - } - - /* - * Set the calibration of this detector element. Must be > 0. - */ - void setCalib(double calib) noexcept(false) { - setCalibCore(calib); - } - - friend std::ostream& operator<<(std::ostream& s, const DetectorElement& de); - - -private: - virtual double getCalibCore() const; - virtual double getCalibCore(double eta, double phi) const; - virtual void setCalibCore(double calib) noexcept(false); - - DetectorElement(const DetectorElement& de) = delete; - DetectorElementType myType; - double myCalib; - -}; - -typedef boost::shared_ptr DetectorElementPtr; - -std::ostream& operator<<(std::ostream& s, const DetectorElement& de); - -} - -#endif /*DETECTORELEMENT_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h b/RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h deleted file mode 100644 index 72663ac16f76a..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DETECTORELEMENTTYPE_HH_ -#define DETECTORELEMENTTYPE_HH_ - - -namespace pftools { -/** - * \class DetectorElementType - * \brief Enumerates possible DetectorElement objects. - * - * Possible detector elements: - * ECAL - * HCAL - * PRESHOWER - * OFFSET - * - * \author Jamie Ballin - * \date April 2008 - */ -enum DetectorElementType { - ECAL = 0, HCAL = 1, PRESHOWER = 2, OFFSET = 3, ECAL2 = 4, HCAL2 = 5 -}; - -const char* const DetElNames[] = { "ECAL", "HCAL", "PRESHOWER", "OFFSET", "ECAL2", "HCAL2" }; - -} -#endif /* DETECTORELEMENTTYPE_HH_ */ diff --git a/RecoParticleFlow/PFClusterTools/interface/Erl_mlp.h b/RecoParticleFlow/PFClusterTools/interface/Erl_mlp.h deleted file mode 100644 index 39d04a9923ec2..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Erl_mlp.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef ERL_MLP_H_ -#define ERL_MLP_H_ -#include -#include -namespace pftools { - -#define THISALGORITHMBECOMINGSKYNETCOST = 9999; - -class Erl_mlp { -public: - Erl_mlp(); - - virtual ~Erl_mlp(); - - void setOffsetAndSlope(const double offset, const double slope) { - offset_ = offset; - slope_ = slope; - } - - double evaluate(const double t1 = 0.0, const double t2 = 0.0, - const double t3 = 0.0, const double t4 = 0.0, - const double t5 = 0.0, const double t6 = 0.0, const double t7 = 0.0) { - t1_ = t1; - t2_ = t2; - t3_ = t3; - t4_ = t4; - t5_ = t5; - t6_ = t6; - t7_ = t7; - - return output(); - } - - double ecalFraction(const double t1 = 0.0, const double t2 = 0.0, - const double t3 = 0.0, const double t4 = 0.0, - const double t5 = 0.0, const double t6 = 0.0, const double t7 = 0.0) { - t1_ = t1; - t2_ = t2; - t3_ = t3; - t4_ = t4; - t5_ = t5; - t6_ = t6; - t7_ = t7; - - return ecalOutput(); - } - -private: - double t1_, t2_, t3_, t4_, t5_, t6_, t7_; - double offset_, slope_; - - inline double transform(const double k) { - return tanh(k); - //return k/2.0; - } - - double output() { - return ((80 * neuron_01190()) - offset_) / slope_; - //return 0; - } - - double ecalOutput() { - return neuron_01200() * 8.0/5.0; - } - - double neuron_01190() { return 5.06272330366805203838e-02 * neuron_01110() + 7.27249962994314103071e-02 * neuron_01100() + 6.87531379353593874448e-01 * neuron_01090() + 5.90999649535358523300e-02 * neuron_01170() + 5.11852363238117641364e-02 * neuron_01160() + 4.49943694412880193512e-02 * neuron_01150() + 4.07425660324388025368e-02 * neuron_01140() + 3.93358734274708785050e-02 * neuron_01130() + 4.19854685691317813800e-02 * neuron_01120(); } - double neuron_01200() { return 2.45908500608800761889e-01 * neuron_01110() + 2.87953657915926142241e-01 * neuron_01100() + 1.12104946100116772967e-01 * neuron_01090() + -2.48512814545735039040e-01 * neuron_01170() + -1.73640293653000848950e-01 * neuron_01160() + -9.57729315919204349239e-02 * neuron_01150() + -1.34634120232926899480e-02 * neuron_01140() + 7.33600499895466356959e-02 * neuron_01130() + 1.62882613167782547281e-01 * neuron_01120(); } - - //Hidden layer: <0.118.0> - double neuron_01090() { return transform(1.77006431112942702599e-01 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + 2.14497710612496367277e-01 * neuron_01050() + 1.43625191299545074131e+00 * neuron_01040() + 1.35895192827592214968e+00 * neuron_01030() + 3.42315251134937381661e-01 * neuron_01020() + 2.12812599023514514851e-01 * neuron_01010()) ; } - double neuron_01100() { return transform(2.43335108048174653117e-02 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -1.54265303752188047415e-02 * neuron_01050() + 5.31887393676174879964e-01 * neuron_01040() + 1.29700229375154463263e+00 * neuron_01030() + -2.51855201382369053853e-01 * neuron_01020() + -5.06439475438290737097e-02 * neuron_01010()) ; } - double neuron_01110() { return transform(2.26240107787991917565e-02 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -5.41830867221511913723e-02 * neuron_01050() + 5.34848607670024622784e-01 * neuron_01040() + 1.31149902444579002925e+00 * neuron_01030() + -2.64338982863860205708e-01 * neuron_01020() + -4.06486696831378502281e-02 * neuron_01010()) ; } - double neuron_01120() { return transform(3.53971299195493110945e-02 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -8.37804537629018991618e-02 * neuron_01050() + 6.07782495555854840319e-01 * neuron_01040() + 1.18563130862724230852e+00 * neuron_01030() + -2.68121286212209153366e-01 * neuron_01020() + -6.12015780590782140780e-02 * neuron_01010()) ; } - double neuron_01130() { return transform(5.69937856406597387338e-02 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -1.00016140981091974926e-01 * neuron_01050() + 7.03662421839865714901e-01 * neuron_01040() + 9.52968317012650611986e-01 * neuron_01030() + -2.73076926608740555569e-01 * neuron_01020() + -7.68552378252462947694e-02 * neuron_01010()) ; } - double neuron_01140() { return transform(8.30357728126230598686e-02 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -1.03499741661745067733e-01 * neuron_01050() + 8.06348739275546733118e-01 * neuron_01040() + 6.38758549749190884803e-01 * neuron_01030() + -2.80508796980343866334e-01 * neuron_01020() + -7.87991143999155069233e-02 * neuron_01010()) ; } - double neuron_01150() { return transform(1.09487813610100057082e-01 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -9.70768580095677652286e-02 * neuron_01050() + 9.10591921032660733815e-01 * neuron_01040() + 2.66241721261271546695e-01 * neuron_01030() + -2.89724454229762784507e-01 * neuron_01020() + -6.80058450136514086592e-02 * neuron_01010()) ; } - double neuron_01160() { return transform(1.32909925381862498162e-01 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -8.45644764303960794205e-02 * neuron_01050() + 1.01870729141489779757e+00 * neuron_01040() + -1.39709767812830482070e-01 * neuron_01030() + -3.01085409364046208136e-01 * neuron_01020() + -4.85758323472233188856e-02 * neuron_01010()) ; } - double neuron_01170() { return transform(1.50514730336528679278e-01 * neuron_01070() + 2.00000000000000011102e-01 * neuron_01060() + -7.16821794819610530469e-02 * neuron_01050() + 1.14442797677888430385e+00 * neuron_01040() + -5.53609997511943840998e-01 * neuron_01030() + -3.18164032162814081062e-01 * neuron_01020() + -2.52943742434275434250e-02 * neuron_01010()) ; } - - //Input layer: <0.108.0> - double neuron_01010() { return t1_; } - double neuron_01020() { return t2_; } - double neuron_01030() { return t3_; } - double neuron_01040() { return t4_; } - double neuron_01050() { return t5_; } - double neuron_01060() { return t6_; } - double neuron_01070() { return t7_; } -}; -} - -#endif /*ERL_MLP_H_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Exercises3.h b/RecoParticleFlow/PFClusterTools/interface/Exercises3.h deleted file mode 100644 index acdf960bfff17..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Exercises3.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef EXERCISES3_H_ -#define EXERCISES3_H_ - -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" -#include "RecoParticleFlow/PFClusterTools/interface/SpaceManager.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h" - -#include -#include -#include -#include -#include -#include - - -namespace pftools { -class IO; - -class Exercises3 { -public: - - Exercises3(IO* options); - - virtual ~Exercises3(); - - void calibrateCalibratables(TChain& sourceTree, - const std::string& exercisefile); - - //void gaussianFits(TFile& exercisefile, std::vector& calibs); - - void evaluateCalibrator(SpaceManagerPtr s, CalibratorPtr c, TTree& tree, - Calibratable* calibrated, DetectorElementPtr ecal, - DetectorElementPtr hcal, DetectorElementPtr offset, CalibrationProvenance cp, CalibrationProvenance cpCorr = NONE); - - - void evaluateSpaceManager(SpaceManagerPtr s, const std::vector& detEls); - - - void setTarget(CalibrationTarget t) { - target_ = t; - } - - - void getCalibrations(SpaceManagerPtr s); - -private: - - Exercises3(const Exercises3&) = delete; - void operator=(const Exercises3&) = delete; -// double lowE_, highE_, lowEta_, highEta_, lowPhi_, highPhi_; -// unsigned divE_, divEta_, divPhi_; - bool withOffset_; - CalibrationTarget target_; - unsigned threshold_; - std::vector elements_; - IO* options_; - std::ofstream calibResultsFile_; - unsigned debug_; - PFClusterCalibration clusterCalibration_; - -}; -} - -#endif /*EXERCISES3_H_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/IO.h b/RecoParticleFlow/PFClusterTools/interface/IO.h deleted file mode 100644 index 7453d5dc3d6ce..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/IO.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef __IO__ -#define __IO__ - -#include -#include - - -#include -#include -// #include -#include -#include - -#ifndef __CINT__ -#include -#endif - - -/// \brief General option file parser -/// -/// \code -/// IO io("myfile.opt"); -/// fECALthresh = 0.05; -/// io.GetOpt("ECAL", "threshold", fECALthresh); -/// \endcode -/// \author Colin Bernet -/// \date January 2002 -namespace pftools { -class IO { - private: - /// all non empty, uncommented lines - std::vector< std::pair< std::string, std::string> > fAllLines; - - /// parse one file - bool ParseFile(const char* filename); - - /// counter - int fCurline; - - /// current key - std::string fCurkey; - - /// current tag - std::string fCurtag; - - - public: - /// maximum line size - static const unsigned sLinesize; - - /// builds IO from files matching filepattern - IO(const char* filepattern); - ~IO() {fAllLines.clear();} - - /// dumps fAllLines - void Dump(std::ostream& out = std::cout) const; - - /// dumps fAllLines - friend std::ostream& operator<<(std::ostream& out, IO& io); - - /// true if constructor went wrong - bool IsZombie() const {return fAllLines.empty();} - -#ifndef __CINT__ - /// reads a vector of T - template - bool GetOpt(const char* tag, const char* key, std::vector< T >& values) const; - - /// reads a T - template - bool GetOpt(const char* tag, const char* key, T& value) const; - - /// reads a string - bool GetOpt(const char* tag, const char* key, std::string& value) const; - - /// \brief reads a vector of T - /// - /// this function allows to read several lines with the same tag/key: - /// \code - /// while ( GetAllOpt(tag, key, values) ) - /// // do something... - /// \endcode - template - bool GetAllOpt(const char* tag, const char* key, std::vector< T >& values); - - /// \brief reads a T - /// - /// this function allows to read several lines with the same tag/key: - /// - /// \code - /// while ( GetAllOpt(tag, key, value) ) - /// // do something... - /// \endcode - template - bool GetAllOpt(const char* tag, const char* key, T& value); - - std::string GetLineData(const char* tag, const char* key) const; - std::string GetNextLineData(const char* tag, const char* key); - - -#endif -}; -} - -#ifndef __CINT__ - -template -bool pftools::IO::GetOpt(const char* tag, const char* key, std::vector< T >& values) const { - std::string data = GetLineData(tag,key); - - std::istringstream in(data); - while(true) { - T tmp; - in>>tmp; - if(!in) break; - values.push_back(tmp); - } - - return true; -} - -template -bool pftools::IO::GetOpt(const char* tag, const char* key, T& value) const { - std::string data = GetLineData(tag,key); - - std::istringstream in(data); - in>>value; - if(in.good()) return true; - else return false; -} - -template -bool pftools::IO::GetAllOpt(const char* tag, const char* key, std::vector< T >& values) { - return false; -} - -template -bool pftools::IO::GetAllOpt(const char* tag, const char* key, T& value) { - std::string data = GetNextLineData(tag, key); - if(data.empty()) return false; - - std::istringstream in(data); - in>>value; - if(in) { - return true; - } - else { - return false; - } -} - - -#endif // __CINT__ - -#endif - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h b/RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h deleted file mode 100644 index 3820325e947ea..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef LINEARCALIBRATOR_HH_ -#define LINEARCALIBRATOR_HH_ - -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" - - -#include "TMatrixD.h" -#include "TVectorD.h" - -/** - * \class LinearCalibrator Class - * - * \brief This class implements the simple "linear" calibration for the "a,b,c" coefficients. - * It extends Calibrator. - * - * Calibrations are given i.t.o, - * E_calib = a + b * det_1 + c * det_2 + ... - * - * - \author Jamie Ballin - \date April 2008 - */ -namespace pftools { -class LinearCalibrator : public Calibrator { -public: - LinearCalibrator(); - ~LinearCalibrator() override; - - - /* - * Note: covariant return type w.r.t. Calibrator class: the overloading has changed - * the return type but this IS allowed with modern compilers. - * See documentation in Calibrator.h - */ - LinearCalibrator* clone() const override; - LinearCalibrator* create() const override; - -protected: - - std::map - getCalibrationCoefficientsCore() noexcept(false) override; - - - LinearCalibrator(const LinearCalibrator& lc); - /* - * Converts the particle deposits into a useful matrix formulation. - */ - virtual void initEijMatrix(TMatrixD& eij, TVectorD& truthE); - - /* - * Utility method to extract the unique number of detected elements. - */ - virtual void populateDetElIndex(); - - virtual TVectorD& getProjections(const TMatrixD& eij, TVectorD& proj, - const TVectorD& truthE) const; - - virtual TMatrixD& getHessian(const TMatrixD& eij, TMatrixD& hess, - const TVectorD& truthE) const; - - /* - * Map to convert detector element to array row/column index. - */ - std::map myDetElIndex; - -}; -} - -#endif /*LINEARCALIBRATOR_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Operators.h b/RecoParticleFlow/PFClusterTools/interface/Operators.h deleted file mode 100644 index 8eee0273658b2..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Operators.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef OPERATORS_H_ -#define OPERATORS_H_ -#include "TH1F.h" -#include -#include -#include - -/** - * Operators.h - * Various operators and handy methods for std::pairs and std::maps - * - * \author Jamie Ballin - * \date May 2008 - */ - -/* - * Pair-wise addition of std::pairs - */ -template std::pair operator+(const std::pair& one, const std::pair& two) { - std::pair r(one.first + two.first, one.second + two.second); - return r; -} - -/* - * Pair-wise subtraction or std::pairs - */ -template std::pair operator-(const std::pair& one, const std::pair& two) { - std::pair r(one.first - two.first, one.second - two.second); - return r; -} - -/* - * Streams std::pair contents to stream - */ -template std::ostream& operator<<(std::ostream& s, const std::pair& aT) { - s << "(" << aT.first << ", " << aT.second << ")"; - return s; -} - -/* - * Extracts the value set from a std::map - */ -template void valueVector(const std::map& extract, std::vector& output) { - for(typename std::map::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) { - output.push_back((*cit).second); - } -} - -/* - * Extracts the key set from a std::map - */ -template void keyVector(const std::map& extract, std::vector& output) { - for(typename std::map::const_iterator cit = extract.begin(); cit != extract.end(); ++cit) { - output.push_back((*cit).first); - } -} - -#endif /*OPERATORS_H_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h b/RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h deleted file mode 100644 index b1efe07fd00f7..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef PFCLUSTERCALIBRATION_H_ -#define PFCLUSTERCALIBRATION_H_ - -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationResultWrapper.h" -//#include "RecoParticleFlow/PFClusterTools/interface/IO.h" - -#include -#include -#include -#include -#include - -class TF1; -class TTree; - -namespace pftools { - -class PFClusterCalibration; -std::ostream& operator<<(std::ostream& s, const PFClusterCalibration& cc); - -/* - * \class PFClusterCalibration - * \brief Calibrated calorimeter cluster energy for hadronic PFCandidates. - * \author Jamie Ballin, Imperial College London - * \date September 2008 - * - * The ECAL and HCAL have been calibrated to 50 GeV electrons. Therefore, a calibration is required - * to evaluate the correct hadronic response. This class will calibrate clusters belonging to a PFCandidate. - * (Users should access these clusters from the blocks in the PFCandidate). - * - * A linear calibration is evaluated, for barrel and endcap (call setBarrelBoundary(double eta) - * to set this limit). - * - * Sensible default values are set for all members, but in order to get usable results, you must supply the - * latest function parameters and corrections (seperately available) - see setCorrections() - * and setEvolutionParameters() documentation below. - */ -class PFClusterCalibration { -public: - - /* Constructor with sensible defaults */ - PFClusterCalibration(); - - //PFClusterCalibration(IO* io); - - virtual ~PFClusterCalibration(); - - /* Returns the calibrated ecalEnergy */ - double getCalibratedEcalEnergy(const double& ecalE, const double& hcalE, - const double& eta, const double& phi) const; - - /* Returns the calibrated hcalEnergy */ - double getCalibratedHcalEnergy(const double& ecalE, const double& hcalE, - const double& eta, const double& phi) const; - - /* DEPRECATED METHOD - do not use. - * - * Returns the calibrated particle energy with the correction - * Note: for, say, ecalOnly particles: - * energy = correction_function([calibrated ecalEnergy + hcalEnergy(v small)]) - * ditto hcalOnly - */ - double getCalibratedEnergy(const double& ecalE, const double& hcalE, - const double& eta, const double& phi) const; - - void getCalibratedEnergyEmbedAInHcal(double& ecalE, - double& hcalE, const double& eta, const double& phi) const; - - /* TESTING purposes only! */ - void calibrate(Calibratable& c); - - /* TESTING purposes only! */ - void getCalibrationResultWrapper(const Calibratable& c, - CalibrationResultWrapper& crw); - - /* TESTING purposes only! */ - void calibrateTree(TTree* tree); - - /* Sets the 'a' term in the abc calibration and a final linear correction. - * You get these values from the (seperately available) option file. */ - void setCorrections(const double& lowEP0, const double& lowEP1, - const double& globalP0, const double& globalP1); - - /* getCalibratedEnergy() returns max(0, calibrated energy) if this is true. */ - void setAllowNegativeEnergy(const bool& allowIt) { - allowNegativeEnergy_ = allowIt; - } - - /* Whether to apply a final correction function in getCalibratedEnergy() - * Highly recommended ('a' term of abc calibration will be neglected otherwise. */ - void setDoCorrection(const int& doCorrection) { - doCorrection_ = doCorrection; - } - - void setDoEtaCorrection(const int doEtaCorrection) { - doEtaCorrection_ = doEtaCorrection; - } - - /* Threshold for ecalOnly and hcalOnly evaluation. */ - void setEcalHcalEnergyCuts(const double& ecalCut, const double& hcalCut) { - //std::cout << __PRETTY_FUNCTION__ << "WARNING! These will be ignored.\n"; - ecalOnlyDiv_ = ecalCut; - hcalOnlyDiv_ = hcalCut; - } - - /* Hard cut between barrel and endcap. */ - void setBarrelBoundary(const double& eta) { - barrelEndcapEtaDiv_ = eta; - } - - void setMaxEToCorrect(double maxE) { - maxEToCorrect_ = maxE; - } - - /* Sets the function parameters - very important! */ - void setEvolutionParameters(const std::string& sector, - const std::vector& params); - - void setEtaCorrectionParameters(const std::vector& params); - - /* Elements in this vector refer to the different calibration functions - * available. For each one of these, you should call setEvolutionParameters() - * with the appropriate vector acquired from an options file. - */ - std::vector* getKnownSectorNames() { - return &names_; - } - - - /* Dumps the member values to the stream */ - friend std::ostream& pftools::operator<<(std::ostream& s, const PFClusterCalibration& cc); - -private: - - void init(); - - //where to select either barrel or endcap - double barrelEndcapEtaDiv_; - - //at what energy to split between ecalOnly, hcalOnly, ecalHcal - double ecalOnlyDiv_; - double hcalOnlyDiv_; - - int doCorrection_; - int allowNegativeEnergy_; - int doEtaCorrection_; - double maxEToCorrect_; - - double correctionLowLimit_; - double globalP0_; - double globalP1_; - double lowEP0_; - double lowEP1_; - - //Function used to correct final total energies - TF1* correction_; - //Function to correct eta dependence (post-calibration). - TF1* etaCorrection_; - - std::map namesAndFunctions_; - std::vector names_; - -}; -} - -#endif /* PFCLUSTERCALIBRATION_H_ */ diff --git a/RecoParticleFlow/PFClusterTools/interface/PFResolutionMapManager.h b/RecoParticleFlow/PFClusterTools/interface/PFResolutionMapManager.h deleted file mode 100644 index 473d9b87bb85c..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/PFResolutionMapManager.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef RecoParticleFlowPFClusterTools_PFResolutionMapManager_h -#define RecoParticleFlowPFClusterTools_PFResolutionMapManager_h -#include "RecoParticleFlow/PFClusterTools/interface/PFResolutionMap.h" - -class PFResolutionMapManager { - public: - PFResolutionMapManager(const char * name); - const PFResolutionMap& GetResolutionMap(bool MapEta,bool Corr); - - private: - PFResolutionMap M1; - PFResolutionMap M2; - PFResolutionMap M3; - PFResolutionMap M4; -}; -#endif diff --git a/RecoParticleFlow/PFClusterTools/interface/PFToolsException.h b/RecoParticleFlow/PFClusterTools/interface/PFToolsException.h deleted file mode 100644 index cf89f44a08536..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/PFToolsException.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PFTOOLSEXCEPTION_H_ -#define PFTOOLSEXCEPTION_H_ - -#include -#include -namespace pftools { -/** - \class PFToolsException - \brief General purpose exception class for use by classes in the pftools namespace - - \author Jamie Ballin - \date April 2008 - */ -class PFToolsException : public std::exception { -public: - PFToolsException(const std::string& aErrorDescription=""); - - ~PFToolsException() noexcept override; - - const char* what() const noexcept override; - -protected: - std::string myDescription; -}; -} - -#endif /*PFTOOLSEXCEPTION_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h b/RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h deleted file mode 100644 index 2f0a4c65c150d..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef PARTICLEDEPOSIT_HH_ -#define PARTICLEDEPOSIT_HH_ - -#include - -#include "RecoParticleFlow/PFClusterTools/interface/Deposition.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" - - -#include - -/** - \class ParticleDeposit - \brief An object that encapsualtes energy depositions (real, MC or otherwise) made by particle in N DetectorElement objects. - - \author Jamie Ballin - \date April 2008 - */ -namespace pftools { - -class ParticleDeposit { -public: - - ParticleDeposit(double truthEnergy = -1.0, double eta = 0, double phi = 0); - virtual ~ParticleDeposit(); - - virtual void addRecDeposition(const Deposition& rec); - virtual void addTruthDeposition(const Deposition& truth); - - virtual const std::vector& getRecDepositions() const; - virtual std::vector getTruthDepositions() const; - - /* - * Returns the overall MC particle energy. - */ - virtual double getTruthEnergy() const { - return myTruthEnergy; - } - - /* - * Returns the detected energy from this detector element, including calibration. - */ - virtual double getRecEnergy(const DetectorElementPtr de) const; - - virtual double getRecEnergy() const; - - virtual void setRecEnergy(const DetectorElementPtr de, double energy); - - virtual double getEnergyResolution() const; - - /* - * Returns the raw MC energy input into this detector element. - */ - virtual double getTruthEnergy(const DetectorElementPtr de) const; - - virtual unsigned getId() const { - return myId; - } - - inline double getEta() const { - return myEta; - } - - virtual double getPhi() const { - return myPhi; - } - - void setTruthEnergy(const double truth) { - myTruthEnergy = truth; - } - - void setPhi(const double phi) { - myPhi = phi; - } - - void setEta(const double eta) { - myEta = eta; - } - - double getTargetFunctionContrib() const; - -private: - static unsigned count; - //ParticleDeposit(const ParticleDeposit& pd); - std::vector myRecDepositions; - std::vector myTruthDepositions; - unsigned myId; - - double myTruthEnergy; - double myEta; - double myPhi; - - /* - * For general ROOT dictionary building happiness! - */ - std::vector pdps_; - // std::vector pds_; -}; - - -typedef boost::shared_ptr ParticleDepositPtr; -std::ostream& operator<<(std::ostream& s, const ParticleDeposit& p); - -} - -#endif /*PARTICLEDEPOSIT_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Region.h b/RecoParticleFlow/PFClusterTools/interface/Region.h deleted file mode 100644 index f19d8c6489137..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Region.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef REGION_HH_ -#define REGION_HH_ - - -namespace pftools { - -enum Region { - NOREGION = 0, BARREL_POS = 1, TRANSITION_POS = 2, ENDCAP_POS = 3 -}; - -const char* const RegionNames[] = { "NOREGION", "BARREL_POS", "TRANSITION_POS", "ENDCAP_POS" }; - - -} -#endif //REGION_HH_ diff --git a/RecoParticleFlow/PFClusterTools/interface/SpaceManager.h b/RecoParticleFlow/PFClusterTools/interface/SpaceManager.h deleted file mode 100644 index bbf7520b5bacd..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/SpaceManager.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef SPACEMANAGER_HH_ -#define SPACEMANAGER_HH_ -#include "RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h" -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/Region.h" -#include -#include -#include -#include -#include -#include -#include -#include -namespace pftools { -/** - \class SpaceManager - \brief A tool to associate SpaceVoxels with Calibrator objects - - \author Jamie Ballin - \date April 2008 - */ -class SpaceManager { -public: - SpaceManager(std::string name); - - virtual ~SpaceManager(); - - std::string getName() { - return name_; - } - - - /* - * Initialises the internal map of calibrators and space voxels according to the - * type of calibrator supplied and the specified eta, phi and energy segmentation. - */ - void createCalibrators(const Calibrator& toClone, const double etaSeg, - const double phiSeg, const double energySeg); - - /* - * As above but only for the specified ranges. - * (Compare with ROOT TH3F histogram constructor!) - */ - void createCalibrators(const Calibrator& toClone, const unsigned nEta, - const double etaMin, const double etaMax, const unsigned nPhi, - const double phiMin, const double phiMax, const unsigned nEnergy, - const double energyMin, const double energyMax) noexcept(false); - - void createCalibrators(const Calibrator& toClone); - - std::map* getCalibrators() { - std::map* ptr = &myAddressBook; - return ptr; - } - - /* - * Adds a calibrator for the specified volume element. - * Returns a pointer to it once it's been created, and returns a pointer to - * any exisitng calibrator should that SpaceVoxel already exist. - */ - CalibratorPtr createCalibrator(const Calibrator& toClone, SpaceVoxelPtr s); - - /* - * Returns a pointer to the calibrator you need for the specified space point. - * Returns 0 if it's not found. - */ - CalibratorPtr findCalibrator(const double eta, const double phi, - const double energy = 0) const; - - void assignCalibration(const CalibratorPtr& c, const std::map& result); - - std::map getCalibration(CalibratorPtr c); - - std::ostream& printCalibrations(std::ostream& stream); - - TH1* extractEvolution(DetectorElementPtr det, Region region, TF1& f1, bool useTruth = true); - - void addEvolution(const DetectorElementPtr& det, Region region, const TF1& f) { - if(region == BARREL_POS) - barrelPosEvolutions_[det] = f; - if(region == ENDCAP_POS) - endcapPosEvolutions_[det] = f; - } - - double interpolateCoefficient(DetectorElementPtr det, double energy, double eta, double phi); - - double evolveCoefficient(DetectorElementPtr det, double energy, double eta, double phi); - - int getNCalibrations() { - return calibrationCoeffs_.size(); - } - void clear(); - - void makeInverseAddressBook(); - - void setBarrelLimit(double limit) { - barrelLimit_ = limit; - } - -private: - - std::string name_; - - double barrelLimit_; - double transitionLimit_; - double endcapLimit_; - - std::map myAddressBook; - std::map inverseAddressBook_; - std::map > calibrationCoeffs_; - std::vector myKnownSpaceVoxels; - - std::vector barrelPosRegion_; - std::vector transitionPosRegion_; - std::vector endcapPosRegion_; - - std::map barrelPosEvolutions_; - std::map endcapPosEvolutions_; - - std::map > regionsToSVs_; - - -}; - -typedef boost::shared_ptr SpaceManagerPtr; - -} -#endif /*SPACEMANAGER_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h b/RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h deleted file mode 100644 index 94f2b4a735a04..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef SPACEVOXEL_HH_ -#define SPACEVOXEL_HH_ -#include -#include -#include - -namespace pftools { - -/**\class SpaceVoxel - \brief A multi-dimensional volume element to subdivide the detector into different calibration regions. - - \author Jamie Ballin - \date April 2008 - */ -class SpaceVoxel { -public: - /* - * Constructs a SpaceVoxel over the specified region. - * - * Upper edges are exclusive; Lower edges are inclusive. - * - * If any of XXXBegin == XXXEnd, then this criterion is ignored and the corresponding - * containsXXX(y) will return true. - */ - SpaceVoxel(double etaBegin = 0, double etaEnd = 0, double phiBegin = 0, - double phiEnd = 0, double energyBegin = 0, double energyEnd = 0, bool ecalValid = true, bool hcalValid = true); - - - virtual ~SpaceVoxel(); - - virtual bool contains(const double& eta, const double& phi, - const double& energy) const; - - virtual bool contains(const double& eta, const double& phi, - const double& energy, const bool& ecalValid, const bool& hcalValid) const; - - virtual bool containsEta(const double& eta) const; - - virtual bool containsPhi(const double& phi) const; - - virtual bool containsEnergy(const double& energy) const; - - double minEnergy() const { - return myEnergyMin; - } - - double maxEnergy() const { - return myEnergyMax; - } - - virtual bool ecalValid() const { - return ecalValid_; - } - - virtual bool hcalValid() const { - return hcalValid_; - } - - void print(std::ostream& s) const; - - void printMsg() { - std::cout << "Hello!\n"; - } - - - //Prints this SpaceVoxel's name into the supplied string - void getName(std::string& s) const; - - friend std::ostream& operator<<(std::ostream& s, - const pftools::SpaceVoxel& sv); - - bool operator()(const SpaceVoxel& sv1, const SpaceVoxel& sv2) ; - - bool operator()(const boost::shared_ptr& sv1, const boost::shared_ptr& sv2) ; - - -private: - double myEtaMin; - double myEtaMax; - double myPhiMin; - double myPhiMax; - double myEnergyMin; - double myEnergyMax; - bool ecalValid_; - bool hcalValid_; - -}; - -typedef boost::shared_ptr SpaceVoxelPtr; - -std::ostream& operator<<(std::ostream& s, const pftools::SpaceVoxel& sv); - -} -#endif /*SPACEVOXEL_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/ToString.h b/RecoParticleFlow/PFClusterTools/interface/ToString.h deleted file mode 100644 index 09b66d32e005f..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/ToString.h +++ /dev/null @@ -1,20 +0,0 @@ - -#ifndef TOSTR_H -#define TOSTR_H -#include -#include -template std::string toString(const T& aT) { - std::ostringstream oss; - oss << aT; - return oss.str(); -} - -template std::string toString(const std::pair& aT) { - std::ostringstream oss; - oss << "(" << aT.first << ", " << aT.second << ")"; - return oss.str(); -} - - -#endif /*TOSTR_H */ - diff --git a/RecoParticleFlow/PFClusterTools/interface/TreeUtility.h b/RecoParticleFlow/PFClusterTools/interface/TreeUtility.h deleted file mode 100644 index 18392f746b98f..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/TreeUtility.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef TREEUTILITY_HH_ -#define TREEUTILITY_HH_ -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" - -#include -#include -#include -#include -#include -#include - -namespace pftools { -/** - * - * \class TreeUtility - \brief Utility class to create particles and detector elements from a Root file - - \todo Remove recreateFromRootFile(TFile& file) as this is only useful for testing purposes! - - \author Jamie Ballin - \date April 2008 - */ -typedef boost::shared_ptr CalibratablePtr; -class TreeUtility { -public: - - TreeUtility(); - virtual ~TreeUtility(); - - unsigned getParticleDepositsDirectly(TChain& sourceChain, - std::vector& toBeFilled, - CalibrationTarget target, DetectorElementPtr offset, - DetectorElementPtr ecal, DetectorElementPtr hcal, bool includeOffset = false); - - unsigned getCalibratablesFromRootFile(TChain& tree, - std::vector& toBeFilled); - - unsigned convertCalibratablesToParticleDeposits( - const std::vector& input, - std::vector& toBeFilled, - CalibrationTarget target, DetectorElementPtr offset, - DetectorElementPtr ecal, DetectorElementPtr hcal, bool includeOffset = false); - - void dumpCaloDataToCSV(TChain& chain, std::string csvFilename, double range, bool gaus = false); - - -private: - std::map vetos_; - -}; -} -#endif /*TREEUTILITY_HH_*/ diff --git a/RecoParticleFlow/PFClusterTools/interface/Utils.h b/RecoParticleFlow/PFClusterTools/interface/Utils.h deleted file mode 100644 index ead51ec2dd64e..0000000000000 --- a/RecoParticleFlow/PFClusterTools/interface/Utils.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __Utils__ -#define __Utils__ - -#include -#include - - -class TCanvas; -class TVector3; - -/// \brief Utility functions -/// -/// \author Colin Bernet -/// \date January 2006 -namespace pftools { -class Utils { - - public: - - /// match a string to a regexp - static bool StringMatch(const char* string, const char* pattern); - - /// divide a TCanvas in a nice way - static TCanvas* DivideCanvas( TCanvas *cv, int nPads ); - - /// get all files matching pattern - static std::vector Glob(const char* pattern); - - /// returns the date - static std::string Date(); - - /// converts a vector (in eta,phi,R) to a vector in (x,y,z) - static TVector3 VectorEPRtoXYZ( const TVector3& posepr ); -}; -} - -#endif - - diff --git a/RecoParticleFlow/PFClusterTools/plugins/BuildFile.xml b/RecoParticleFlow/PFClusterTools/plugins/BuildFile.xml deleted file mode 100644 index 570ec663fdbac..0000000000000 --- a/RecoParticleFlow/PFClusterTools/plugins/BuildFile.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterTools/plugins/CalibratableTest.cc b/RecoParticleFlow/PFClusterTools/plugins/CalibratableTest.cc deleted file mode 100644 index 3e527ad2f3f91..0000000000000 --- a/RecoParticleFlow/PFClusterTools/plugins/CalibratableTest.cc +++ /dev/null @@ -1,311 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/CalibratableTest.h" -#include "DataFormats/ParticleFlowReco/interface/PFSimParticle.h" -#include "DataFormats/ParticleFlowReco/interface/PFSimParticleFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlockElementFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFBlock.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFTrack.h" -#include "DataFormats/ParticleFlowReco/interface/PFNuclearInteraction.h" -#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" -#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" -#include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h" -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/Math/interface/LorentzVector.h" - -using namespace edm; -using namespace pftools; -using namespace reco; - -CalibratableTest::CalibratableTest(const edm::ParameterSet& parameters) : - debug_(0), nParticleWrites_(0), nParticleFails_(0), nEventWrites_(0), nEventFails_(0), - deltaRCandToSim_(0.4) { - - std::cout << __PRETTY_FUNCTION__ << std::endl; - - /* This procedure is GENERIC to storing any dictionary enable class in a ROOT tree. */ - tree_ = fileservice_->make("CalibratableTest", ""); - calib_ = new Calibratable(); - tree_->Branch("Calibratable", "pftools::Calibratable", &calib_, 32000, 2); - - inputTagCandidates_= parameters.getParameter("PFCandidates"); - inputTagSimParticles_= parameters.getParameter("PFSimParticles"); - inputTagClustersEcal_= parameters.getParameter("PFClustersEcal"); - inputTagClustersHcal_= parameters.getParameter("PFClustersHcal"); - deltaRCandToSim_ = parameters.getParameter("deltaRCandToSim"); - debug_= parameters.getParameter("debug"); -} - -CalibratableTest::~CalibratableTest() { - -} - -void CalibratableTest::beginJob() { - if (debug_ > 1) - std::cout << __PRETTY_FUNCTION__ << "\n"; - -} - -void CalibratableTest::analyze(const edm::Event& event, - const edm::EventSetup& iSetup) { - if (debug_ > 1) - std::cout << __PRETTY_FUNCTION__ << "\n"; - - //Extract new collection references - pfCandidates_ = new Handle; - simParticles_ = new Handle; - clustersEcal_ = new Handle; - clustersHcal_ = new Handle; - - getCollection(*pfCandidates_, inputTagCandidates_, event); - getCollection(*simParticles_, inputTagSimParticles_, event); - getCollection(*clustersEcal_, inputTagClustersEcal_, event); - getCollection(*clustersHcal_, inputTagClustersHcal_, event); - - //Reset calibratable branch - thisEventPasses_ = true; - thisParticlePasses_ = true; - calib_->reset(); - - if (debug_ > 1) - std::cout << "\tStarting event..."<< std::endl; - - PFSimParticleCollection sims = **simParticles_; - PFCandidateCollection candidates = **pfCandidates_; - PFClusterCollection clustersEcal = **clustersEcal_; - PFClusterCollection clustersHcal = **clustersHcal_; - - if (sims.empty()) { - std::cout << "\tNo sim particles found!" << std::endl; - thisEventPasses_ = false; - } - - //Find primary pions in the event - std::vector primarySims = findPrimarySimParticles(sims); - if (debug_) { - std::cout << "\tFound "<< primarySims.size() - << " primary sim particles, "<< (**pfCandidates_).size() << " pfCandidates\n"; - } - for (std::vector::const_iterator cit = primarySims.begin(); cit - != primarySims.end(); ++cit) { - //There will be one write to the tree for each pion found. - if (debug_ > 1) - std::cout << "\t**Starting particle...**\n"; - const PFSimParticle& sim = sims[*cit]; - //One sim per calib => - calib_->sim_numEvent_ = 1; - calib_->sim_isMC_ = true; - calib_->sim_energyEvent_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().E(); - calib_->sim_phi_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().Phi(); - calib_->sim_eta_ = sim.trajectoryPoint(PFTrajectoryPoint::ClosestApproach).momentum().Eta(); - - if (sim.nTrajectoryPoints() > PFTrajectoryPoint::ECALEntrance) { - calib_->sim_etaEcal_ = sim.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Eta(); - calib_->sim_phiEcal_ = sim.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Phi(); - } - if (sim.nTrajectoryPoints() > PFTrajectoryPoint::HCALEntrance) { - calib_->sim_etaHcal_ = sim.trajectoryPoint(PFTrajectoryPoint::HCALEntrance).positionREP().Eta(); - calib_->sim_phiHcal_ = sim.trajectoryPoint(PFTrajectoryPoint::HCALEntrance).positionREP().Phi(); - } - - // Find candidates near this sim particle - std::vector matchingCands = findCandidatesInDeltaR(sim, - candidates, deltaRCandToSim_); - if (debug_ > 3) - std::cout << "\t\tFound candidates near sim, found " - << matchingCands.size()<< " of them.\n"; - if (matchingCands.empty()) - thisParticlePasses_ = false; - for (std::vector::const_iterator mcIt = matchingCands.begin(); mcIt - != matchingCands.end(); ++mcIt) { - const PFCandidate& theCand = candidates[*mcIt]; - extractCandidate(theCand); - } - //Finally, - fillTreeAndReset(); - - } - - delete pfCandidates_; - delete simParticles_; - delete clustersEcal_; - delete clustersHcal_; - - if (thisEventPasses_) - ++nEventWrites_; - else - ++nEventFails_; - -} - -std::vector CalibratableTest::findPrimarySimParticles( - const std::vector& sims) { - std::vector answers; - unsigned index(0); - for (std::vector::const_iterator cit = sims.begin(); cit - != sims.end(); ++cit) { - PFSimParticle theSim = *cit; - //TODO: what about rejected events? - if (theSim.motherId() >= 0) - continue; - int particleId = abs(theSim.pdgCode()); - if (particleId != 211) - continue; - //TODO: ...particularly interacting pions? - if (!theSim.daughterIds().empty()) - continue; - answers.push_back(index); - ++index; - } - return answers; -} - -void CalibratableTest::extractCandidate(const PFCandidate& cand) { - if (debug_ > 3) - std::cout << "\tCandidate: "<< cand << "\n"; - - //There may be several PFCandiates per sim particle. So we create a mini-class - //to represent each one. CandidateWrapper is defined in Calibratable. - //It's very easy to use, as we shall see... - CandidateWrapper cw; - cw.energy_ = cand.energy(); - cw.eta_ = cand.eta(); - cw.phi_ = cand.phi(); - cw.type_ = cand.particleId(); - cw.energyEcal_ = cand.ecalEnergy(); - cw.energyHcal_ = cand.hcalEnergy(); - if (debug_ > 4) - std::cout << "\t\tECAL energy = " << cand.ecalEnergy() - << ", HCAL energy = " << cand.hcalEnergy() << "\n"; - - //Now, extract block elements from the pfCandidate: - PFCandidate::ElementsInBlocks eleInBlocks = cand.elementsInBlocks(); - if (debug_ > 3) - std::cout << "\tLooping over elements in blocks, " - << eleInBlocks.size() << " of them."<< std::endl; - for (PFCandidate::ElementsInBlocks::iterator bit = eleInBlocks.begin(); bit - != eleInBlocks.end(); ++bit) { - - /* - * Find PFClusters associated with this candidate. - */ - - //Extract block reference - PFBlockRef blockRef((*bit).first); - //Extract index - unsigned indexInBlock((*bit).second); - //Dereference the block (what a palava!) - const PFBlock& block = *blockRef; - //And finally get a handle on the elements - const edm::OwnVector & elements = block.elements(); - //get references to the candidate's track, ecal clusters and hcal clusters - switch (elements[indexInBlock].type()) { - case PFBlockElement::ECAL: { - reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef(); - const PFCluster theRealCluster = *clusterRef; - CalibratableElement d(theRealCluster.energy(), - theRealCluster.positionREP().eta(), theRealCluster.positionREP().phi(), theRealCluster.layer() ); - calib_->cluster_ecal_.push_back(d); - if (debug_ > 4) - std::cout << "\t\tECAL cluster: "<< theRealCluster << "\n"; - - break; - } - - case PFBlockElement::HCAL: { - reco::PFClusterRef clusterRef = elements[indexInBlock].clusterRef(); - const PFCluster theRealCluster = *clusterRef; - CalibratableElement d(theRealCluster.energy(), - theRealCluster.positionREP().eta(), theRealCluster.positionREP().phi(), theRealCluster.layer() ); - calib_->cluster_hcal_.push_back(d); - if (debug_ > 4) - std::cout << "\t\tHCAL cluster: "<< theRealCluster << "\n"; - - break; - } - - default: - if (debug_ > 3) - std::cout << "\t\tOther block type: " - << elements[indexInBlock].type() << "\n"; - break; - } - - } - //For each candidate found, - calib_->cands_.push_back(cw); -} - -std::vector CalibratableTest::findCandidatesInDeltaR( - const PFSimParticle& pft, const std::vector& cands, - const double& deltaRCut) { - - unsigned index(0); - std::vector answers; - - double trEta = pft.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Eta(); - double trPhi = pft.trajectoryPoint(PFTrajectoryPoint::ECALEntrance).positionREP().Phi(); - - for (std::vector::const_iterator cit = cands.begin(); cit - != cands.end(); ++cit) { - - PFCandidate cand = *cit; - double cEta = cand.eta(); - double cPhi = cand.phi(); - - if (deltaR(cEta, trEta, cPhi, trPhi) < deltaRCut) { - //accept - answers.push_back(index); - } - - ++index; - } - return answers; -} - -void CalibratableTest::fillTreeAndReset() { - if (thisEventPasses_ && thisParticlePasses_) { - ++nParticleWrites_; - calib_->recompute(); - if (debug_> 4) { - //print a summary - std::cout << *calib_; - } - tree_->Fill(); - } else { - ++nParticleFails_; - } - if (debug_ > 1) - std::cout << "\t**Finished particle.**\n"; - calib_->reset(); -} - -void CalibratableTest::endJob() { - - if (debug_> 0) { - std::cout << __PRETTY_FUNCTION__ << std::endl; - - std::cout << "\tnParticleWrites: "<< nParticleWrites_ - << ", nParticleFails: "<< nParticleFails_ << "\n"; - std::cout << "\tnEventWrites: "<< nEventWrites_ << ", nEventFails: " - << nEventFails_ << "\n"; - std::cout << "Leaving "<< __PRETTY_FUNCTION__ << "\n"; - } - -} - -double CalibratableTest::deltaR(const double& eta1, const double& eta2, - const double& phi1, const double& phi2) { - double deltaEta = fabs(eta1 - eta2); - double deltaPhi = fabs(phi1 - phi2); - if (deltaPhi > M_PI) { - deltaPhi = 2 * M_PI- deltaPhi; - } - return sqrt(pow(deltaEta, 2) + pow(deltaPhi, 2)); -} - - diff --git a/RecoParticleFlow/PFClusterTools/plugins/modules.cc b/RecoParticleFlow/PFClusterTools/plugins/modules.cc deleted file mode 100644 index 63993193fc9a4..0000000000000 --- a/RecoParticleFlow/PFClusterTools/plugins/modules.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/CalibratableTest.h" -DEFINE_FWK_MODULE(CalibratableTest); - diff --git a/RecoParticleFlow/PFClusterTools/python/CalibrationParametersECAL_cff.py b/RecoParticleFlow/PFClusterTools/python/CalibrationParametersECAL_cff.py deleted file mode 100644 index c4d7dadc1b133..0000000000000 --- a/RecoParticleFlow/PFClusterTools/python/CalibrationParametersECAL_cff.py +++ /dev/null @@ -1,7 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -#--- initialize calibration parameters for energy deposits of electrons and photons in ECAL; -# E_calib = pf_ECAL_calib_p0 + E_raw * pf_ECAL_calib_p1 -pf_ECAL_calib_p0 = cms.double(0.0) -pf_ECAL_calib_p1 = cms.double(1.0) - diff --git a/RecoParticleFlow/PFClusterTools/src/CalibCompare.cc b/RecoParticleFlow/PFClusterTools/src/CalibCompare.cc deleted file mode 100644 index e7ddb27c05812..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/CalibCompare.cc +++ /dev/null @@ -1,200 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/CalibCompare.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" -#include "RecoParticleFlow/PFClusterTools/interface/TreeUtility.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/SpaceManager.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" -#include "RecoParticleFlow/PFClusterTools/interface/Region.h" -#include "RecoParticleFlow/PFClusterTools/interface/IO.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace pftools; - -CalibCompare::~CalibCompare() { -} - -CalibCompare::CalibCompare(IO* options) : - withOffset_(false), target_(CLUSTER), options_(options), debug_(0), - mlpOffset_(0.0), mlpSlope_(1.0) { - - options_->GetOpt("exercises", "withOffset", withOffset_); - options_->GetOpt("exercises", "debug", debug_); - - /* Initialise PFClusterCalibration appropriately. */ - double g0, g1, e0, e1; - options_->GetOpt("correction", "globalP0", g0); - options_->GetOpt("correction", "globalP1", g1); - options_->GetOpt("correction", "lowEP0", e0); - options_->GetOpt("correction", "lowEP1", e1); - clusterCalibration_.setCorrections(e0, e1, g0, g1); - - double ecalECut, hcalECut; - options_->GetOpt("evolution", "ecalECut", ecalECut); - options_->GetOpt("evolution", "hcalECut", hcalECut); - clusterCalibration_.setEcalHcalEnergyCuts(ecalECut, hcalECut); - - int allowNegative(0); - options_->GetOpt("correction", "allowNegativeEnergy", allowNegative); - clusterCalibration_.setAllowNegativeEnergy(allowNegative); - - int doCorrection(1); - options_->GetOpt("correction", "doCorrection", doCorrection); - clusterCalibration_.setDoCorrection(doCorrection); - - int doEtaCorrection(0); - options_->GetOpt("correction", "doEtaCorrection", doEtaCorrection); - clusterCalibration_.setDoEtaCorrection(doEtaCorrection); - - double barrelEta; - options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEta); - clusterCalibration_.setBarrelBoundary(barrelEta); - - double maxEToCorrect(100.0); - options_->GetOpt("correction", "maxEToCorrect", maxEToCorrect); - clusterCalibration_.setMaxEToCorrect(maxEToCorrect); - - std::vector* names = clusterCalibration_.getKnownSectorNames(); - for (std::vector::iterator i = names->begin(); i - != names->end(); ++i) { - std::string sector = *i; - std::vector params; - options_->GetOpt("evolution", sector.c_str(), params); - clusterCalibration_.setEvolutionParameters(sector, params); - } - - std::vector etaParams; - options_->GetOpt("evolution", "etaCorrection", etaParams); - clusterCalibration_.setEtaCorrectionParameters(etaParams); - - std::cout << clusterCalibration_ << "\n"; - - options_->GetOpt("correction", "mlpOffset", mlpOffset_); - options_->GetOpt("correction", "mlpSlope", mlpSlope_); - - erlCalibration_.setOffsetAndSlope(mlpOffset_, mlpSlope_); - - if (debug_ > 0) - std::cout << __PRETTY_FUNCTION__ << ": finished.\n"; - -} - -void CalibCompare::calibrateCalibratables(TChain& sourceTree, - const std::string& exercisefile) { - - if (debug_ > 0) { - std::cout << "Welcome to " << __PRETTY_FUNCTION__ << "\n"; - std::cout << "Opening TTree...\n"; - } - - TreeUtility tu; - std::vector calibVec; - - tu.getCalibratablesFromRootFile(sourceTree, calibVec); - - std::cout << "Moving on... " << std::endl; - TFile* exercises = new TFile(exercisefile.c_str(), "recreate"); - TTree tree("CalibratedParticles", ""); - Calibratable* calibrated = new Calibratable(); - tree.Branch("Calibratable", "pftools::Calibratable", &calibrated, 32000, 2); - - evaluateCalibrations(tree, calibrated, calibVec); - - //save results - std::cout << "Writing output tree...\n"; - tree.Write(); - //gaussianFits(*exercises, calibVec); - exercises->Write(); - exercises->Close(); - std::cout << "Done." << std::endl; - delete calibrated; - -} - -void CalibCompare::evaluateCalibrations(TTree& tree, Calibratable* calibrated, - const std::vector& calibVec) { - - unsigned count(0); - for (std::vector::const_iterator zit = calibVec.begin(); zit - != calibVec.end(); ++zit) { - - const Calibratable& calib = *zit; - - calibrated->reset(); - - CalibrationResultWrapper crwPre; - crwPre.ecalEnergy_ = calib.cluster_energyEcal_; - crwPre.hcalEnergy_ = calib.cluster_energyHcal_; - crwPre.particleEnergy_ = calib.cluster_energyEcal_ - + calib.cluster_energyHcal_; - crwPre.truthEnergy_ = calib.sim_energyEvent_; - crwPre.provenance_ = UNCALIBRATED; - crwPre.targetFuncContrib_ = 0; - crwPre.target_ = target_; - crwPre.compute(); - calibrated->calibrations_.push_back(crwPre); - - CalibrationResultWrapper crwErl; - - crwErl.particleEnergy_ = erlCalibration_.evaluate(crwPre.ecalEnergy_, - crwPre.hcalEnergy_, calib.cluster_numEcal_, - calib.cluster_numHcal_, fabs(calib.cluster_meanEcal_.eta_) - / 2.0, crwPre.ecalEnergy_ / (crwPre.particleEnergy_), - (calib.cluster_meanEcal_.phi_ + 3.14) / 6.3); - crwErl.ecalEnergy_ = crwErl.particleEnergy_ - * erlCalibration_.ecalFraction(crwPre.ecalEnergy_, - crwPre.hcalEnergy_, calib.cluster_numEcal_, - calib.cluster_numHcal_, fabs( - calib.cluster_meanEcal_.eta_) / 2.0, - crwPre.ecalEnergy_ / (crwPre.particleEnergy_), - (calib.cluster_meanEcal_.phi_ + 3.14) / 6.3); - - crwErl.hcalEnergy_ = crwErl.particleEnergy_ - crwErl.ecalEnergy_; - crwErl.b_ = crwErl.ecalEnergy_ / crwPre.ecalEnergy_; - crwErl.c_ = crwErl.hcalEnergy_ / crwPre.hcalEnergy_; - - crwErl.truthEnergy_ = calib.sim_energyEvent_; - crwErl.provenance_ = BAYESIAN; - crwErl.target_ = target_; - crwErl.compute(); - calibrated->calibrations_.push_back(crwErl); - - CalibrationResultWrapper crwCorr; - - crwCorr.ecalEnergy_ = clusterCalibration_.getCalibratedEcalEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, - calib.cluster_meanEcal_.eta_, calib.cluster_meanEcal_.phi_); - crwCorr.hcalEnergy_ = clusterCalibration_.getCalibratedHcalEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, - calib.cluster_meanHcal_.eta_, calib.cluster_meanHcal_.phi_); - crwCorr.particleEnergy_ = clusterCalibration_.getCalibratedEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, calib.sim_etaEcal_, - calib.sim_phiEcal_); - - crwCorr.truthEnergy_ = calib.sim_energyEvent_; - crwCorr.provenance_ = LINEAR; - crwCorr.targetFuncContrib_ = 0;; - crwCorr.target_ = target_; - crwCorr.compute(); - calibrated->calibrations_.push_back(crwCorr); - - calibrated->recompute(); - - tree.Fill(); - - ++count; - } - -} - diff --git a/RecoParticleFlow/PFClusterTools/src/Calibrator.cc b/RecoParticleFlow/PFClusterTools/src/Calibrator.cc deleted file mode 100644 index 3ff1d5087d5fe..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/Calibrator.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -using namespace pftools; - -//DetectorElement* Calibrator::offsetElement = new DetectorElement(OFFSET); - -Calibrator::Calibrator(){ - -} - -Calibrator::~Calibrator() { -} - -void Calibrator::addDetectorElement(DetectorElementPtr const de) { - //std::cout << "myDetecotElements has size: " << myDetectorElements.size() << "before addition.\n"; - myDetectorElements.push_back(de); -} -void Calibrator::addParticleDeposit(ParticleDepositPtr pd) { - myParticleDeposits.push_back(pd); -} - -std::map Calibrator::getCalibrationCoefficientsCore() noexcept(false) { - - std::cout << __PRETTY_FUNCTION__ - << ": Not implemented in default Calibrator class!\n"; - std::cout << "\tWARNING: returning empty map.\n"; - std::map answers; - return answers; -} - -//DetectorElementPtr Calibrator::getOffsetElementCore() { -// DetectorElementPtr el(offsetElement); -// return el; -//} diff --git a/RecoParticleFlow/PFClusterTools/src/Deposition.cc b/RecoParticleFlow/PFClusterTools/src/Deposition.cc deleted file mode 100644 index 119bb27656f1b..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/Deposition.cc +++ /dev/null @@ -1,16 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/Deposition.h" -using namespace pftools; -Deposition::Deposition(DetectorElementPtr element, double eta, double phi, - double energy, double depth) : - myElementPtr(element), myEta(eta), myPhi(phi), myEnergy(energy), - myDepth(depth) { -} - -Deposition::~Deposition() { -} - -std::ostream& pftools::operator<<(std::ostream& s, const Deposition& d) { - s << "Deposit's type: "<< *(d.getDetectorElement()) << "\tE:\t"<< d.getEnergy() - << ", \teta:\t"<< d.getEta() << ", \tmyPhi:\t"<< d.getPhi() << "\n"; - return s; -} diff --git a/RecoParticleFlow/PFClusterTools/src/DetectorElement.cc b/RecoParticleFlow/PFClusterTools/src/DetectorElement.cc deleted file mode 100644 index 5ed26b303416c..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/DetectorElement.cc +++ /dev/null @@ -1,43 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" -#include -using namespace pftools; -//A comment -DetectorElement::DetectorElement(DetectorElementType type, double calib) : - myType(type), myCalib(calib) { - -} - -void DetectorElement::setCalibCore(double calib) noexcept(false) { - //I'll tolerate very small negative numbers (artefacts of the minimisation algo - //but otherwise this shouldn't be allowed. -// if(calib > -0.01) { - myCalib = calib; -// } -// else { -// MinimiserException me("Setting calibration <= 0!"); -// throw me; -// } -} - -double DetectorElement::getCalibCore() const { - if(myType == OFFSET && myCalib == 1) { - return 1.0; - } - return myCalib; -} - -double DetectorElement::getCalibCore(double eta, double phi) const { - return getCalib(); -} - -DetectorElement::~DetectorElement() { -} - - -std::ostream& pftools::operator<<(std::ostream& s, const DetectorElement& de) { - s << "DetectorElement: " << pftools::DetElNames[de.getType()] << ", \tcalib: " << de.getCalib(); - - return s; -} - diff --git a/RecoParticleFlow/PFClusterTools/src/Erl_mlp.cc b/RecoParticleFlow/PFClusterTools/src/Erl_mlp.cc deleted file mode 100644 index dffe2280bc07a..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/Erl_mlp.cc +++ /dev/null @@ -1,18 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/Erl_mlp.h" -#include "TH1F.h" - -using namespace pftools; - - -Erl_mlp::Erl_mlp() -{ - -} - -Erl_mlp::~Erl_mlp() -{ -} - - - - diff --git a/RecoParticleFlow/PFClusterTools/src/Exercises3.cc b/RecoParticleFlow/PFClusterTools/src/Exercises3.cc deleted file mode 100644 index 472b19da14f33..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/Exercises3.cc +++ /dev/null @@ -1,510 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/Exercises3.h" -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" -#include "RecoParticleFlow/PFClusterTools/interface/TreeUtility.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h" -#include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h" -#include "RecoParticleFlow/PFClusterTools/interface/SpaceManager.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" -#include "RecoParticleFlow/PFClusterTools/interface/Region.h" -#include "RecoParticleFlow/PFClusterTools/interface/IO.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace pftools; - -void resetElement3(DetectorElementPtr de) { - de->setCalib(1.0); -} - -Exercises3::~Exercises3() { - calibResultsFile_.close(); -} - -Exercises3::Exercises3(IO* options) : - withOffset_(false), target_(CLUSTER), threshold_(30), options_(options), - debug_(0) { - - options_->GetOpt("exercises", "withOffset", withOffset_); - options_->GetOpt("exercises", "threshold", threshold_); - options_->GetOpt("exercises", "debug", debug_); - - /* Initialise PFClusterCalibration appropriately. */ - double g0, g1, e0, e1; - options_->GetOpt("correction", "globalP0", g0); - options_->GetOpt("correction", "globalP1", g1); - options_->GetOpt("correction", "lowEP0", e0); - options_->GetOpt("correction", "lowEP1", e1); - clusterCalibration_.setCorrections(e0, e1, g0, g1); - - double ecalECut, hcalECut; - options_->GetOpt("evolution", "ecalECut", ecalECut); - options_->GetOpt("evolution", "hcalECut", hcalECut); - clusterCalibration_.setEcalHcalEnergyCuts(ecalECut, hcalECut); - - int allowNegative(0); - options_->GetOpt("correction", "allowNegativeEnergy", allowNegative); - clusterCalibration_.setAllowNegativeEnergy(allowNegative); - - int doCorrection(1); - options_->GetOpt("correction", "doCorrection", doCorrection); - clusterCalibration_.setDoCorrection(doCorrection); - - int doEtaCorrection(0); - options_->GetOpt("correction", "doEtaCorrection", doEtaCorrection); - clusterCalibration_.setDoEtaCorrection(doEtaCorrection); - - double barrelEta; - options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEta); - clusterCalibration_.setBarrelBoundary(barrelEta); - - double maxEToCorrect(100.0); - options_->GetOpt("correction", "maxEToCorrect", maxEToCorrect); - clusterCalibration_.setMaxEToCorrect(maxEToCorrect); - - std::vector* names = clusterCalibration_.getKnownSectorNames(); - for (std::vector::iterator i = names->begin(); i - != names->end(); ++i) { - std::string sector = *i; - std::vector params; - options_->GetOpt("evolution", sector.c_str(), params); - clusterCalibration_.setEvolutionParameters(sector, params); - } - - std::vector etaParams; - options_->GetOpt("evolution", "etaCorrection", etaParams); - clusterCalibration_.setEtaCorrectionParameters(etaParams); - - std::cout << clusterCalibration_ << "\n"; - - std::string outputFileName; - options_->GetOpt("results", "calibParamOutput", outputFileName); - calibResultsFile_.open(outputFileName.c_str()); - calibResultsFile_ << "//Hello from your friendly PFClusterTools!\n"; - if (debug_ > 0) - std::cout << __PRETTY_FUNCTION__ << ": finished.\n"; - -} - -void Exercises3::calibrateCalibratables(TChain& sourceTree, - const std::string& exercisefile) { - - if (debug_ > 0) { - std::cout << "Welcome to "<< __PRETTY_FUNCTION__ << "\n"; - std::cout << "Opening TTree...\n"; - } -// //open tfile -// TFile* source = new TFile(sourcefile.c_str()); -// if (source == 0) { -// std::string desc("Couldn't open file "); -// desc += sourcefile; -// PFToolsException e(desc); -// throw e; -// } -// if (debug_ > 0) -// std::cout << "Extracting calibratables...\n"; - //use tree utility to extract calibratables - TreeUtility tu; - std::vector calibVec; - - tu.getCalibratablesFromRootFile(sourceTree, calibVec); - if (debug_ > 0) - std::cout << "Got a vector of calibratables of size "<< calibVec.size() - << "\n"; - //initialise detector elements - DetectorElementPtr ecal(new DetectorElement(ECAL, 1.0)); - DetectorElementPtr hcal(new DetectorElement(HCAL, 1.0)); - DetectorElementPtr offset(new DetectorElement(OFFSET, 1.0)); - - //convert calibratables to particle deposits - std::vector pdVec; - tu.convertCalibratablesToParticleDeposits(calibVec, pdVec, target_, offset, - ecal, hcal, withOffset_); - //source->Close(); - - TFile* exercises = new TFile(exercisefile.c_str(), "recreate"); - TH1F droppedParticles("droppedParticles", "droppedParticles", 100000, 0, - 100000); - if (debug_ > 0) - std::cout << "Particle deposit vec has "<< pdVec.size() << " entries\n"; - - //calibrate - if (debug_ > 1) - std::cout << "Creating calibrator clones and space managers\n"; - boost::shared_ptr linCal(new LinearCalibrator()); - - //Tell the calibrator which detector elements should be calibrated - if (withOffset_) { - linCal->addDetectorElement(offset); - - } - linCal->addDetectorElement(ecal); - linCal->addDetectorElement(hcal); - - double barrelEta; - options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEta); - boost::shared_ptr sm(new SpaceManager("ecalAndHcal")); - sm->setBarrelLimit(barrelEta); - sm->createCalibrators(*linCal); - - if (debug_ > 1) - std::cout << "Initialised SpaceManager and calibrators.\n"; - elements_.clear(); - if (withOffset_) - elements_.push_back(offset); - elements_.push_back(ecal); - elements_.push_back(hcal); - - //Initialise calibrators with particles - int dropped(0); - - double eCut(0.0); - double hCut(0.0); - options_->GetOpt("evolution", "ecalECut", eCut); - options_->GetOpt("evolution", "hcalECut", hCut); - if (debug_ > 0) - std::cout << "Using a ECAL and HCAL energy cuts of "<< eCut << " and " - << hCut << " GeV\n"; - if (debug_ > 1) - std::cout << "Assigning particles to space managers and calibrators.\n"; - - //This is just a convenience plot to check on the hcal - for (std::vector::const_iterator cit = pdVec.begin(); cit - != pdVec.end(); ++cit) { - ParticleDepositPtr pd = *cit; - CalibratorPtr c = sm->findCalibrator(pd->getEta(), pd->getPhi(), - pd->getTruthEnergy()); - //std::cout << *pd << "\n"; - if (c == nullptr) { - std::cout << "Couldn't find calibrator for particle?!\n"; - std::cout << "\t"<< *pd << "\n"; - - dropped++; - } else { - c->addParticleDeposit(pd); - } - - } - - if (debug_ > 1) - std::cout << "Dropped "<< dropped << " particles.\n"; - - /* Done assignments, now calibrate */ - if (debug_ > 1) - std::cout - << "Assignments complete, starting calibration and analysis.\n"; - - //calibrate - std::map * smCalibrators = - sm->getCalibrators(); - - TTree tree("CalibratedParticles", ""); - Calibratable* calibrated = new Calibratable(); - tree.Branch("Calibratable", "pftools::Calibratable", &calibrated, 32000, 2); - if (debug_ > 1) - std::cout << "Initialised tree.\n"; - - /* ECAL and HCAL */ - std::cout << "*** Performance for ECAL + HCAL calibration ***\n"; - getCalibrations(sm); - exercises->cd("/"); - exercises->mkdir("ecalAndHcal"); - exercises->cd("/ecalAndHcal"); - evaluateSpaceManager(sm, elements_); - for (std::map::iterator it = - smCalibrators->begin(); it != smCalibrators->end(); ++it) { - SpaceVoxelPtr sv = (*it).first; - CalibratorPtr c = (*it).second; - std::for_each(elements_.begin(), elements_.end(), resetElement3); - evaluateCalibrator(sm, c, tree, calibrated, ecal, hcal, offset, LINEAR, - LINEARCORR); - - std::for_each(elements_.begin(), elements_.end(), resetElement3); - } - sm->printCalibrations(std::cout); - - exercises->cd("/"); - - //save results - std::cout << "Writing output tree...\n"; - tree.Write(); - droppedParticles.Write(); - //gaussianFits(*exercises, calibVec); - exercises->Write(); - exercises->Close(); - std::cout << "Done."<< std::endl; - -} - -void Exercises3::getCalibrations(SpaceManagerPtr s) { - - std::map* smCalibrators = s->getCalibrators(); - - for (std::map::iterator it = - smCalibrators->begin(); it != smCalibrators->end(); ++it) { - CalibratorPtr c= (*it).second; - std::for_each(elements_.begin(), elements_.end(), resetElement3); - if (c->hasParticles() > static_cast(threshold_)) { - std::map calibs = - c->getCalibrationCoefficients(); - s->assignCalibration(c, calibs); - } - } -} - -void Exercises3::evaluateSpaceManager(SpaceManagerPtr s, - const std::vector& detEls) { - - int autoFit(0); - options_->GetOpt("evolution", "autoFit", autoFit); - std::cout << "AutoFit option = "<< autoFit << "\n"; - - std::vector ecalBarrel; - std::vector ecalEndcap; - std::vector hcalBarrel; - std::vector hcalEndcap; - - double minE, maxE; - options_->GetOpt("evolution", "evolutionFunctionMinE", minE); - options_->GetOpt("evolution", "evolutionFunctionMaxE", maxE); - - int basePlots(0); - options_->GetOpt("evolution", "basePlots", basePlots); - - int useTruth(1); - options_->GetOpt("evolution", "basePlotsUseTruth", useTruth); - - if (debug_ > 1&& basePlots > 0) - std::cout << "Option to generate evolution plots invoked.\n"; - - if (autoFit == 0) { - std::cout << "Fixing parameters for evolution functions.\n"; - - options_->GetOpt("evolution", "ecalHcalEcalBarrel", ecalBarrel); - options_->GetOpt("evolution", "ecalHcalEcalEndcap", ecalEndcap); - options_->GetOpt("evolution", "ecalHcalHcalBarrel", hcalBarrel); - options_->GetOpt("evolution", "ecalHcalHcalEndcap", hcalEndcap); - assert(ecalBarrel.size() == 6 && ecalEndcap.size() == 6); - assert(hcalBarrel.size() == 6 && hcalEndcap.size() == 6); - - for (std::vector::const_iterator i = detEls.begin(); i - != detEls.end(); ++i) { - DetectorElementPtr d = *i; - std::cout << "Fixing evolution for "<< *d << "\n"; - int mode(0); - options_->GetOpt("spaceManager", "interpolationMode", mode); - - std::string name("Func_"); - name.append(DetElNames[d->getType()]); - name.append("_"); - - /* Fitting for barrel */ - std::string barrelName(name); - barrelName.append(RegionNames[BARREL_POS]); - std::cout << "\tFixing "<< RegionNames[BARREL_POS]<< "\n"; - TF1 - fBarrel(barrelName.c_str(), - "([0]*[5]*x)*([5]*x<[1])+([2]+[3]*exp([4]*[5]*x))*([5]*x>[1])"); - - if (d->getType() == ECAL) { - unsigned count(0); - for (std::vector::const_iterator dit = - ecalBarrel.begin(); dit!= ecalBarrel.end(); ++dit) { - fBarrel.FixParameter(count, *dit); - ++count; - } - - } - if (d->getType() == HCAL) { - unsigned count(0); - for (std::vector::const_iterator dit = - hcalBarrel.begin(); dit!= hcalBarrel.end(); ++dit) { - fBarrel.FixParameter(count, *dit); - ++count; - } - - } - if (useTruth) - fBarrel.FixParameter(5, 1.0); - - fBarrel.SetMinimum(0); - s->addEvolution(d, BARREL_POS, fBarrel); - - if (basePlots > 0) { - TH1* slices = s->extractEvolution(d, BARREL_POS, fBarrel, - useTruth); - slices->Write(); - } - fBarrel.Write(); - - /* Fitting for endcap */ - std::string endcapName(name); - endcapName.append(RegionNames[ENDCAP_POS]); - std::cout << "\tFixing "<< RegionNames[ENDCAP_POS]<< "\n"; - TF1 - fEndcap(endcapName.c_str(), - "([0]*[5]*x)*([5]*x<[1])+([2]+[3]*exp([4]*[5]*x))*([5]*x>[1])"); - - - if (d->getType() == ECAL) { - unsigned count(0); - for (std::vector::const_iterator dit = - ecalEndcap.begin(); dit!= ecalEndcap.end(); ++dit) { - fEndcap.FixParameter(count, *dit); - ++count; - } - - } - if (d->getType() == HCAL) { - unsigned count(0); - for (std::vector::const_iterator dit = - hcalEndcap.begin(); dit!= hcalEndcap.end(); ++dit) { - fEndcap.FixParameter(count, *dit); - ++count; - } - - } - if (useTruth) - fEndcap.FixParameter(5, 1.0); - - fEndcap.SetMinimum(0); - s->addEvolution(d, ENDCAP_POS, fEndcap); - if (basePlots > 0) { - TH1* slices = s->extractEvolution(d, ENDCAP_POS, fEndcap, - useTruth); - slices->Write(); - } - fEndcap.Write(); - } - - } - -} - -void Exercises3::evaluateCalibrator(SpaceManagerPtr s, CalibratorPtr c, - TTree& tree, Calibratable* calibrated, DetectorElementPtr ecal, - DetectorElementPtr hcal, DetectorElementPtr offset, - CalibrationProvenance cp, CalibrationProvenance cpCorr) { - - if (c->hasParticles() > static_cast(threshold_)) { - std::map calibs = s->getCalibration(c); - - std::vector csParticles = c->getParticles(); - unsigned count(0); - int mode(0); - options_->GetOpt("spaceManager", "interpolationMode", mode); - if (debug_ > 1) { - std::cout << "Using interpolation mode " << mode << "\n"; - } - - for (std::vector::iterator zit = csParticles.begin(); zit - != csParticles.end(); ++zit) { - ParticleDepositPtr pd = *zit; - calibrated->reset(); - calibrated->rechits_meanEcal_.energy_ = pd->getRecEnergy(ecal); - calibrated->rechits_meanHcal_.energy_ = pd->getRecEnergy(hcal); - calibrated->sim_energyEvent_ = pd->getTruthEnergy(); - calibrated->sim_etaEcal_ = pd->getEta(); - - for (std::map::iterator deit = - calibs.begin(); deit != calibs.end(); ++deit) { - DetectorElementPtr de = (*deit).first; - de->setCalib(1.0); - } - - CalibrationResultWrapper crwPre; - crwPre.ecalEnergy_ = pd->getRecEnergy(ecal); - crwPre.hcalEnergy_ = pd->getRecEnergy(hcal); - crwPre.particleEnergy_ = pd->getRecEnergy(); - crwPre.truthEnergy_ = pd->getTruthEnergy(); - crwPre.provenance_ = UNCALIBRATED; - crwPre.targetFuncContrib_ = pd->getTargetFunctionContrib(); - crwPre.target_ = target_; - crwPre.compute(); - calibrated->calibrations_.push_back(crwPre); - - double tempEnergy = pd->getRecEnergy(); - //evaluate calibration - for (std::map::iterator deit = - calibs.begin(); deit != calibs.end(); ++deit) { - DetectorElementPtr de = (*deit).first; - - if (mode == 1) - de->setCalib(s->interpolateCoefficient(de, - pd->getTruthEnergy(), pd->getEta(), pd->getPhi())); - else if (mode == 2|| mode == 3|| mode == 4) - de->setCalib(s->evolveCoefficient(de, tempEnergy, - pd->getEta(), pd->getPhi())); - else - de->setCalib((*deit).second); - } - if (debug_ > 8) { - std::cout << "POST ECAL HCAL coeff: " << ecal->getCalib() << ", " << hcal->getCalib() << "\n"; - } - - CalibrationResultWrapper crwPos; - crwPos.ecalEnergy_ = pd->getRecEnergy(ecal); - crwPos.hcalEnergy_ = pd->getRecEnergy(hcal); - crwPos.b_ = ecal->getCalib(); - crwPos.c_ = hcal->getCalib(); - crwPos.particleEnergy_ = pd->getRecEnergy(); - crwPos.truthEnergy_ = pd->getTruthEnergy(); - crwPos.provenance_ = cp; - crwPos.compute(); - - crwPos.targetFuncContrib_ = pd->getTargetFunctionContrib(); - crwPos.target_ = target_; - calibrated->calibrations_.push_back(crwPos); - - //same again, but applying correction - if (cpCorr != NONE) { - CalibrationResultWrapper crwCorr; - - crwCorr.ecalEnergy_ - = clusterCalibration_.getCalibratedEcalEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, - pd->getEta(), pd->getPhi()); - crwCorr.hcalEnergy_ - = clusterCalibration_.getCalibratedHcalEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, - pd->getEta(), pd->getPhi()); - if (debug_ > 8) { - if(crwPre.ecalEnergy_ > 0 && crwPre.hcalEnergy_ >0) - std::cout << "CORR ECAL HCAL coeff: " << crwCorr.ecalEnergy_ / crwPre.ecalEnergy_ << ", " << crwCorr.hcalEnergy_/ crwPre.hcalEnergy_ << "\n\n"; - } - - crwCorr.particleEnergy_ - = clusterCalibration_.getCalibratedEnergy( - crwPre.ecalEnergy_, crwPre.hcalEnergy_, - pd->getEta(), pd->getPhi()); - - crwCorr.b_ = ecal->getCalib(); - crwCorr.c_ = hcal->getCalib(); - - crwCorr.truthEnergy_ = pd->getTruthEnergy(); - crwCorr.provenance_ = cpCorr; - crwCorr.targetFuncContrib_ = pd->getTargetFunctionContrib(); - crwCorr.target_ = target_; - crwCorr.compute(); - calibrated->calibrations_.push_back(crwCorr); - - crwPos.targetFuncContrib_ = pd->getTargetFunctionContrib(); - crwPos.target_ = target_; - calibrated->calibrations_.push_back(crwPos); - } - tree.Fill(); - ++count; - - } - } -} - diff --git a/RecoParticleFlow/PFClusterTools/src/IO.cc b/RecoParticleFlow/PFClusterTools/src/IO.cc deleted file mode 100644 index 6e9b98dcd33d4..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/IO.cc +++ /dev/null @@ -1,175 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/IO.h" -#include "RecoParticleFlow/PFClusterTools/interface/Utils.h" -#include - -using namespace std; -using namespace pftools; - -const unsigned IO::sLinesize = 1000; - -IO::IO(const char* filepattern) : fCurline(0) { - // loop on all files matching pattern, store each non empty line in - // fAllLines for efficient searches later. - cout< files = Utils::Glob(filepattern); - - if( files.empty() ) { - string err = "IO::IO : no files verify pattern "; - err += filepattern; - throw err; - } - - for(unsigned i=0; i>tag; - - if(!strncmp(tag.c_str(),"//",2)) continue; // remove commented lines can be done better ... - - lin.get(data,sLinesize); - - fAllLines.push_back(pair(tag, data)); - } while(in.good()); - - if(in.eof()) { - cout<<"ok"<>readkey; - - if(readkey == key) { - // data.erase(); - // string skey = key; - // int start = pos+skey.size(); - // data.assign(fAllLines[i].second, start, data.size()-start); - found=true; - in.get(data,sLinesize); - } - } - } - if(found) return string(data); - else return string(); -} - -string IO::GetNextLineData(const char* tag, const char* key) { - - if(fCurtag != tag || fCurkey != key) { - // not the same request - fCurline = 0; - fCurtag = tag; - fCurkey = key; - } - // cout<>readkey; - - if(readkey == key) { - found=true; - in.get(data,sLinesize); - fCurline=i+1; - break; - } - } - } - if(found) return string(data); - else return string(); -} - - -bool IO::GetOpt(const char* tag, const char* key, string& value) const { - string data = GetLineData(tag,key); - - char cstr[sLinesize]; - istringstream in(data); - in.get(cstr,sLinesize); - - - value = cstr; - if(!value.empty()) { - // remove leading spaces - int pos = value.find_first_not_of(" \t"); - value = value.substr(pos); - // remove trailing spaces - pos = value.find_last_not_of(" \t"); - value = value.substr(0,pos+1); - } - if(!value.empty()) return true; - else return false; -} - - - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterTools/src/LinearCalibrator.cc b/RecoParticleFlow/PFClusterTools/src/LinearCalibrator.cc deleted file mode 100644 index 4f7d6a9783099..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/LinearCalibrator.cc +++ /dev/null @@ -1,215 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/LinearCalibrator.h" -#include -#include -#include "TVector.h" -#include "TDecompLU.h" -#include "TDecompSVD.h" - -#include "TDecompBK.h" - -#include - -using namespace pftools; - -/* These utility functions allow you to print matrices and vectors to a stream, - * and copy and paste the output directly into Octave or Matlab - */ -void printMat(std::ostream& s, const TMatrixD& input) { - s << "\t["; - for (int i(0); i < input.GetNrows(); i++) { - for (int j(0); j < input.GetNcols(); j++) { - s << input[i][j]<< ", \t"; - } - if (i != (input.GetNrows() - 1)) { - s << ";\n"; - s << "\t"; - } - } - s << "\t]\n"; -} - -void printVec(std::ostream& s, const TVectorD& input) { - s << "\t["; - for (int i(0); i < input.GetNrows(); i++) { - s << input[i]; - if (i != (input.GetNrows() - 1)) { - s << ",\n\t"; - } - } - s << "\t]\n"; -} - -LinearCalibrator::LinearCalibrator() { - -} - -LinearCalibrator::~LinearCalibrator() { -} -LinearCalibrator* LinearCalibrator::clone() const { - return new LinearCalibrator(*this); -} - -LinearCalibrator::LinearCalibrator(const LinearCalibrator& lc) { - myDetectorElements = lc.myDetectorElements; - myParticleDeposits = lc.myParticleDeposits; -} - -LinearCalibrator* LinearCalibrator::create() const { - return new LinearCalibrator(); -} - -std::map LinearCalibrator::getCalibrationCoefficientsCore() - noexcept(false) { -// std::cout << __PRETTY_FUNCTION__ -// << ": determining linear calibration coefficients...\n"; - if (!hasParticles()) { - //I have no particles to calibrate to - throw exception. - PFToolsException me("Calibrator has no particles for calibration!"); - throw me; - } - //std::cout << "\tGetting eij matrix...\n"; - TMatrixD eij; - TVectorD truthE; - initEijMatrix(eij, truthE); - -// std::cout << "\tEij matrix:\n"; -// printMat(std::cout, eij); - - //std::cout << "\tGetting projections...\n"; - TVectorD proj; - TMatrixD hess; - - getProjections(eij, proj, truthE); - //std::cout << "\tProjections:\n"; - //printVec(std::cout, proj); - getHessian(eij, hess, truthE); - - TDecompLU lu; - lu.SetMatrix(hess); - //std::cout << "\tHessian:\n"; - //printMat(std::cout, hess); - - lu.SetTol(1e-25); - TMatrixD hessInv = lu.Invert(); - //std::cout <<"\tInverse Hessian:\n"; - //printMat(std::cout, hessInv); - TVectorD calibsSolved(eij.GetNcols()); - - bool ok(true); - calibsSolved = lu.Solve(proj, ok); - if (ok) { - //std::cout << "\tLU reports ok.\n"; - } - else { - std::cout << "\tWARNING: LU reports NOT ok.\n"; - //This usually happens when you've asked the calibrator to solve for the 'a' term, without including - //a dummy 'a' term in each particle deposit. - //Make sure you do - //Deposition dOffset(offset, eta, phi, 1.0); - //particle->addRecDeposition(dOffset); - //particle->addTruthDeposition(dOffset); - std::cout - << "\tDid you forget to add a dummy offset deposition to each particle?\n"; - std::cout << "\tThrowing an exception!"<< std::endl; - PFToolsException - me("TDecompLU did not converge successfully when finding calibrations. Did you forget to add a dummy offset deposition to each particle?"); - throw me; - } - - //std::cout << "\tCalibrations: \n"; - //printVec(std::cout, calibsSolved); - - std::map answers; - for (std::map::iterator it = - myDetElIndex.begin(); it != myDetElIndex.end(); ++it) { - DetectorElementPtr de = (*it).first; - answers[de] = calibsSolved[(*it).second]; - } - return answers; -} - -void LinearCalibrator::initEijMatrix(TMatrixD& eij, TVectorD& truthE) { - //std::cout << __PRETTY_FUNCTION__ << "\n"; - //std::cout << "\tGetting detector element indices...\n"; - populateDetElIndex(); - eij.Clear(); - eij.Zero(); - - truthE.ResizeTo(myParticleDeposits.size()); - truthE.Zero(); - - //First determine number of calibration constants. - - eij.ResizeTo(myParticleDeposits.size(), myDetElIndex.size()); - - //loop over all particle deposits - unsigned index(0); - for (std::vector::const_iterator cit = - myParticleDeposits.begin(); cit != myParticleDeposits.end(); ++cit) { - ParticleDepositPtr p = *cit; - //get each of the relevant detector elements - - for (std::vector::const_iterator detElIt = - myDetectorElements.begin(); detElIt != myDetectorElements.end(); ++detElIt) { - DetectorElementPtr de = *detElIt; - eij[index][myDetElIndex[de]] = p->getRecEnergy(de); - //truthE[p->getId()] += p->getTruthEnergy(de); - } - truthE[index] = p->getTruthEnergy(); - ++index; - } - -} - -TVectorD& LinearCalibrator::getProjections(const TMatrixD& eij, TVectorD& proj, - const TVectorD& truthE) const { - //std::cout << __PRETTY_FUNCTION__ << "\n"; - proj.ResizeTo(eij.GetNcols()); - proj.Zero(); - - for (int j(0); j < eij.GetNcols(); ++j) { - for (int i(0); i < eij.GetNrows(); ++i) { - proj[j] += eij[i][j] / truthE[i]; - } - } - - return proj; -} - -TMatrixD& LinearCalibrator::getHessian(const TMatrixD& eij, TMatrixD& hess, - const TVectorD& truthE) const { - //std::cout << __PRETTY_FUNCTION__ << "\n"; - unsigned nCalibs(eij.GetNcols()); - hess.ResizeTo(nCalibs, nCalibs); - hess.Zero(); - - for (unsigned i(0); i < nCalibs; ++i) { - for (unsigned j(0); j < nCalibs; ++j) { - for (int n(0); n < eij.GetNrows(); ++n) { - hess[i][j] += eij[n][i] * eij[n][j]/ pow(truthE[n], 2.0); - } - } - } - - return hess; -} - -void LinearCalibrator::populateDetElIndex() { - //reserve index = 0 for the constant term, if we're told to compute it - unsigned index(0); - - myDetElIndex.clear(); - //loop over known detector elements, and assign a unique row/column index to each - for (std::vector::const_iterator cit = - myDetectorElements.begin(); cit != myDetectorElements.end(); ++cit) { - DetectorElementPtr de = *cit; - //std::cout << "\tGot element: "<< *de; - //check we don't have duplicate detector elements - if (myDetElIndex.count(de) == 0) { - myDetElIndex[de] = index; - ++index; - } - } - -} - diff --git a/RecoParticleFlow/PFClusterTools/src/PFClusterCalibration.cc b/RecoParticleFlow/PFClusterTools/src/PFClusterCalibration.cc deleted file mode 100644 index c17097b31b24e..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/PFClusterCalibration.cc +++ /dev/null @@ -1,324 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/PFClusterCalibration.h" -#include "DataFormats/ParticleFlowReco/interface/CalibrationProvenance.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" - -#include -#include -#include -#include -#include - -using namespace pftools; - -void PFClusterCalibration::init() { - - //std::cout << __PRETTY_FUNCTION__ << std::endl; - correction_ = new TF1("correction", - "((x-[0])/[1])*(x>[4])+((x-[2])/[3])*(x<[4])"); - etaCorrection_ - = new TF1( "etaCorrection", - "(1-[0]*x-[1]*x*x)*(x<[2])+([3]+[4]*x)*(x>[2]&&x<[5])+(1-[6]*x-[7]*x*x)*(x>[5])"); - - correction_->FixParameter(0, globalP0_); - correction_->FixParameter(1, globalP1_); - correction_->FixParameter(2, lowEP0_); - correction_->FixParameter(3, lowEP1_); - correction_->FixParameter(4, correctionLowLimit_); - - /* These are the types of calibration I know about: - * ecalOnly_elementName - * etc. Sorry, it's not very nice, but well, neither is ROOT... */ - - std::string eheb("ecalHcalEcalBarrel"); - names_.push_back(eheb); - std::string ehee("ecalHcalEcalEndcap"); - names_.push_back(ehee); - std::string ehhb("ecalHcalHcalBarrel"); - names_.push_back(ehhb); - std::string ehhe("ecalHcalHcalEndcap"); - names_.push_back(ehhe); - - /* char - * funcString("([0]*[5]*x*([1]-[5]*x)/pow(([2]+[5]*x),3)+[3]*pow([5]*x, 0.1))*([5]*x<[8] && [5]*x>[7])+[4]*([5]*x>[8])+([6]*[5]*x)*([5]*x<[7])"); - */ - - const char* - funcString("([0]*[5]*x)*([5]*x<=[1])+([2]+[3]*exp([4]*[5]*x))*([5]*x>[1])"); - - //Create functions for each sector - for (std::vector::const_iterator cit = names_.begin(); cit - != names_.end(); ++cit) { - std::string name = *cit; - TF1 func(name.c_str(), funcString); - //some sensible defaults - func.FixParameter(0, 1); - func.FixParameter(1, 0); - func.FixParameter(2, 1); - func.FixParameter(3, 0); - func.FixParameter(4, 0); - func.FixParameter(5, 1); - - func.SetMinimum(0); - //Store in map - namesAndFunctions_[name] = func; - - } -} - -/*PFClusterCalibration::PFClusterCalibration(IO* options_) : - barrelEndcapEtaDiv_(1.0), ecalOnlyDiv_(0.3), hcalOnlyDiv_(0.5), - doCorrection_(1), allowNegativeEnergy_(0), doEtaCorrection_(1), - maxEToCorrect_(-1.0), correctionLowLimit_(0.), globalP0_(0.0), - globalP1_(1.0), lowEP0_(0.0), lowEP1_(1.0) { - - init(); - - double g0, g1, e0, e1; - options_->GetOpt("correction", "globalP0", g0); - options_->GetOpt("correction", "globalP1", g1); - options_->GetOpt("correction", "lowEP0", e0); - options_->GetOpt("correction", "lowEP1", e1); - setCorrections(e0, e1, g0, g1); - - options_->GetOpt("correction", "allowNegativeEnergy", allowNegativeEnergy_); - options_->GetOpt("correction", "doCorrection", doCorrection_); - options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEndcapEtaDiv_); - - std::vector* names = getKnownSectorNames(); - for (std::vector::iterator i = names->begin(); i - != names->end(); ++i) { - std::string sector = *i; - std::vector params; - options_->GetOpt("evolution", sector.c_str(), params); - setEvolutionParameters(sector, params); - } - - options_->GetOpt("evolution", "doEtaCorrection", doEtaCorrection_); - - std::vector etaParams; - options_->GetOpt("evolution", "etaCorrection", etaParams); - setEtaCorrectionParameters(etaParams); - -} */ - -PFClusterCalibration::PFClusterCalibration() : - barrelEndcapEtaDiv_(1.0), ecalOnlyDiv_(0.3), hcalOnlyDiv_(0.5), - doCorrection_(1), allowNegativeEnergy_(0), doEtaCorrection_(1), - maxEToCorrect_(-1.0), correctionLowLimit_(0.), globalP0_(0.0), - globalP1_(1.0), lowEP0_(0.0), lowEP1_(1.0) { - // std::cout << __PRETTY_FUNCTION__ << std::endl; - init(); - // std::cout - // << "WARNING! PFClusterCalibration evolution functions have not yet been initialised - ensure this is done.\n"; - // std::cout << "PFClusterCalibration construction complete."<< std::endl; - -} - -PFClusterCalibration::~PFClusterCalibration() { - delete correction_; - delete etaCorrection_; -} - -void PFClusterCalibration::setEtaCorrectionParameters(const std::vector& params) { - if (params.size() != 6) { - std::cout << __PRETTY_FUNCTION__ << ": params is of the wrong length." - << std::endl; - return; - } - // std::cout << "Fixing eta correction:\n\t"; - unsigned count(0); - for (std::vector::const_iterator dit = params.begin(); dit - != params.end(); ++dit) { - //std::cout << *dit << "\t"; - etaCorrection_->FixParameter(count, *dit); - ++count; - } - // std::cout << std::endl; - /*for(double eta(0); eta < 2.5; eta += 0.05) { - std::cout << "Eta = " << eta << ",\tcorr = " << etaCorrection_->Eval(eta) << "\n"; - }*/ -} - -void PFClusterCalibration::setEvolutionParameters(const std::string& sector, - const std::vector& params) { - TF1* func = &(namesAndFunctions_.find(sector)->second); - unsigned count(0); - //std::cout << "Fixing for "<< sector << "\n"; - for (std::vector::const_iterator dit = params.begin(); dit - != params.end(); ++dit) { - func->FixParameter(count, *dit); - //std::cout << "\t"<< count << ": "<< *dit; - ++count; - } - // std::cout << std::endl; - func->SetMinimum(0); -} - -void PFClusterCalibration::setCorrections(const double& lowEP0, - const double& lowEP1, const double& globalP0, const double& globalP1) { - //'a' term is -globalP0/globalP1 - globalP0_ = globalP0; - globalP1_ = globalP1; - //Specifically for low energies... - lowEP0_ = lowEP0; - lowEP1_ = lowEP1; - //Intersection of two straight lines => matching at... - correctionLowLimit_ = (lowEP0_ - globalP0_)/(globalP1_ - lowEP1_); - - correction_->FixParameter(0, globalP0_); - correction_->FixParameter(1, globalP1_); - correction_->FixParameter(2, lowEP0_); - correction_->FixParameter(3, lowEP1_); - correction_->FixParameter(4, correctionLowLimit_); - - // std::cout << __PRETTY_FUNCTION__ << ": setting correctionLowLimit_ = " - // << correctionLowLimit_ << "\n"; -} - -double PFClusterCalibration::getCalibratedEcalEnergy(const double& ecalE, - const double& hcalE, const double& eta, const double& phi) const { - const TF1* theFunction(nullptr); - - if (fabs(eta) < barrelEndcapEtaDiv_) { - //barrel - theFunction = &(namesAndFunctions_.find("ecalHcalEcalBarrel")->second); - } else { - //endcap - theFunction = &(namesAndFunctions_.find("ecalHcalEcalEndcap")->second); - } - - assert(theFunction != nullptr); - double totalE(ecalE + hcalE); - double bCoeff = theFunction->Eval(totalE); - return ecalE * bCoeff; -} - -double PFClusterCalibration::getCalibratedHcalEnergy(const double& ecalE, - const double& hcalE, const double& eta, const double& phi) const { - const TF1* theFunction(nullptr); - - if (fabs(eta) < barrelEndcapEtaDiv_) { - //barrel - theFunction = &(namesAndFunctions_.find("ecalHcalHcalBarrel")->second); - } else { - //endcap - theFunction = &(namesAndFunctions_.find("ecalHcalHcalEndcap")->second); - } - - double totalE(ecalE + hcalE); - assert(theFunction != nullptr); - double cCoeff = theFunction->Eval(totalE); - return hcalE * cCoeff; -} - -double PFClusterCalibration::getCalibratedEnergy(const double& ecalE, - const double& hcalE, const double& eta, const double& phi) const { - double totalE(ecalE + hcalE); - double answer(totalE); - - answer = getCalibratedEcalEnergy(ecalE, hcalE, eta, phi) - + getCalibratedHcalEnergy(ecalE, hcalE, eta, phi); - if (doEtaCorrection_) - answer = answer/etaCorrection_->Eval(eta); - - if (maxEToCorrect_> 0 && answer < maxEToCorrect_) - return correction_->Eval(answer); - if (doCorrection_) { - if (maxEToCorrect_> 0 && answer < maxEToCorrect_) - answer = correction_->Eval(answer); - else if (maxEToCorrect_ < 0) { - answer = correction_->Eval(answer); - } - } - if (!allowNegativeEnergy_ && answer < 0) - return 0; - return answer; - -} - -void PFClusterCalibration::getCalibratedEnergyEmbedAInHcal(double& ecalE, - double& hcalE, const double& eta, const double& phi) const { - - double ecalEOld(ecalE); - double hcalEOld(hcalE); - - ecalE = getCalibratedEcalEnergy(ecalEOld, hcalEOld, eta, phi); - hcalE = getCalibratedHcalEnergy(ecalEOld, hcalEOld, eta, phi); - - double preCorrection(ecalE + hcalE); - if (doEtaCorrection_) - preCorrection = preCorrection/etaCorrection_->Eval(eta); - - if (doCorrection_) { - double corrE = correction_->Eval(preCorrection); - //a term = difference - double a = corrE - preCorrection; - hcalE += a; - } - if (hcalE < 0 && !allowNegativeEnergy_) - hcalE = 0; - -} - -void PFClusterCalibration::calibrate(Calibratable& c) { - CalibrationResultWrapper crw; - getCalibrationResultWrapper(c, crw); - c.calibrations_.push_back(crw); - -} - -void PFClusterCalibration::getCalibrationResultWrapper(const Calibratable& c, - CalibrationResultWrapper& crw) { - - crw.ecalEnergy_ = getCalibratedEcalEnergy(c.cluster_energyEcal_, - c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), - fabs(c.cluster_meanEcal_.phi_)); - - crw.hcalEnergy_ = getCalibratedHcalEnergy(c.cluster_energyEcal_, - c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), - fabs(c.cluster_meanEcal_.phi_)); - - crw.particleEnergy_ = getCalibratedEnergy(c.cluster_energyEcal_, - c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), - fabs(c.cluster_meanEcal_.phi_)); - - crw.provenance_ = LINEARCORR; - crw.b_ = crw.ecalEnergy_ / c.cluster_energyEcal_; - crw.c_ = crw.hcalEnergy_ / c.cluster_energyHcal_; - crw.truthEnergy_ = c.sim_energyEvent_; - -} - -void PFClusterCalibration::calibrateTree(TTree* input) { - std::cout << __PRETTY_FUNCTION__ - << ": WARNING! This isn't working properly yet!\n"; - TBranch* calibBr = input->GetBranch("Calibratable"); - Calibratable* calib_ptr = new Calibratable(); - calibBr->SetAddress(&calib_ptr); - - // TBranch* newBranch = input->Branch("NewCalibratable", - // "pftools::Calibratable", &calib_ptr, 32000, 2); - - std::cout << "Looping over tree's "<< input->GetEntries() - << " entries...\n"; - for (unsigned entries(0); entries < 20000; entries++) { - if (entries % 10000== 0) - std::cout << "\tProcessing entry "<< entries << "\n"; - input->GetEntry(entries); - calibrate(*calib_ptr); - input->Fill(); - } - //input.Write("",TObject::kOverwrite); -} - -std::ostream& pftools::operator<<(std::ostream& s, const PFClusterCalibration& cc) { - s << "PFClusterCalibration: dump...\n"; - s << "barrelEndcapEtaDiv:\t" << cc.barrelEndcapEtaDiv_ << ", ecalOnlyDiv:\t" << cc.ecalOnlyDiv_; - s << ", \nhcalOnlyDiv:\t" << cc.hcalOnlyDiv_ << ", doCorrection:\t" << cc.doCorrection_; - s << ", \nallowNegativeEnergy:\t" << cc.allowNegativeEnergy_; - s << ", \ncorrectionLowLimit:\t" << cc.correctionLowLimit_ << ",parameters:\t" << cc.globalP0_ << ", "; - s << cc.globalP1_ << ", " << cc.lowEP0_ << ", " << cc.lowEP1_; - s << "\ndoEtaCorrection:\t" << cc.doEtaCorrection_; - return s; -} - diff --git a/RecoParticleFlow/PFClusterTools/src/PFResolutionMapManager.cc b/RecoParticleFlow/PFClusterTools/src/PFResolutionMapManager.cc deleted file mode 100644 index 3ad3045e6d72e..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/PFResolutionMapManager.cc +++ /dev/null @@ -1,29 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/PFResolutionMapManager.h" -#include -#include - -using namespace std; - -PFResolutionMapManager::PFResolutionMapManager(const char * mapfile){ - TFile f(mapfile); - TH2D *hSEtaC = (TH2D*)f.Get("Sigma_Eta_WithECorrection"); - TH2D *hSEta = (TH2D*)f.Get("Sigma_Eta"); - TH2D *hSPhiC = (TH2D*)f.Get("Sigma_Phi_WithECorrection"); - TH2D *hSPhi = (TH2D*)f.Get("Sigma_Phi"); - - M1 = PFResolutionMap(*hSEtaC); - M2 = PFResolutionMap(*hSEta); - M3 = PFResolutionMap(*hSPhiC); - M4 = PFResolutionMap(*hSPhi); -} - -const PFResolutionMap& PFResolutionMapManager::GetResolutionMap(bool MapEta,bool Corr){ - if(MapEta){ - if(Corr) return M1; - else return M2; - } - else{ - if(Corr) return M3; - else return M4; - } -} diff --git a/RecoParticleFlow/PFClusterTools/src/PFToolsException.cc b/RecoParticleFlow/PFClusterTools/src/PFToolsException.cc deleted file mode 100644 index 66069e2930edd..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/PFToolsException.cc +++ /dev/null @@ -1,17 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/PFToolsException.h" - - -using namespace pftools; - -PFToolsException::PFToolsException(const std::string& aErrorDescription) -{ - myDescription = aErrorDescription; -} - -PFToolsException::~PFToolsException() noexcept -{ -} - -const char* PFToolsException::what() const noexcept { - return myDescription.c_str(); -} diff --git a/RecoParticleFlow/PFClusterTools/src/ParticleDeposit.cc b/RecoParticleFlow/PFClusterTools/src/ParticleDeposit.cc deleted file mode 100644 index 8b8020f8d859b..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/ParticleDeposit.cc +++ /dev/null @@ -1,114 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/ParticleDeposit.h" -#include -#include -#include -#include "RecoParticleFlow/PFClusterTools/interface/DetectorElementType.h" -using namespace pftools; - -unsigned ParticleDeposit::count = 0; - -ParticleDeposit::ParticleDeposit(double truthEnergy, double eta, double phi) : - myId(count), myTruthEnergy(truthEnergy), myEta(eta), myPhi(phi) { - ++count; -} - -ParticleDeposit::~ParticleDeposit() { -} - -void ParticleDeposit::addRecDeposition(const Deposition& rec) { - myRecDepositions.push_back(rec); -} - -void ParticleDeposit::addTruthDeposition(const Deposition& truth) { - myTruthDepositions.push_back(truth); -} - -std::vector ParticleDeposit::getTruthDepositions() const { - return myTruthDepositions; -} - -const std::vector& ParticleDeposit::getRecDepositions() const { - return myRecDepositions; -} - -double ParticleDeposit::getRecEnergy(const DetectorElementPtr de) const { - double energy(0); - for (std::vector::const_iterator cit = myRecDepositions.begin(); cit - != myRecDepositions.end(); ++cit) { - Deposition d = *cit; - - if (d.getDetectorElement()->getType() == de->getType()) { - energy += de->getCalib(d.getEta(), d.getPhi()) * d.getEnergy(); - } - - } - return energy; -} - -void ParticleDeposit::setRecEnergy(const DetectorElementPtr de, double energy) { - for (std::vector::const_iterator cit = myRecDepositions.begin(); cit - != myRecDepositions.end(); ++cit) { - Deposition d = *cit; - - if (d.getDetectorElement()->getType() == de->getType()) { - d.setEnergy(energy); - } - - } -} - -double ParticleDeposit::getTruthEnergy(const DetectorElementPtr de) const { - double energy(0); - for (std::vector::const_iterator - cit = myTruthDepositions.begin(); cit!= myTruthDepositions.end(); ++cit) { - Deposition d = *cit; - if (d.getDetectorElement() == de) { - energy += d.getEnergy(); - } - } - assert(!(energy > 0)); - return energy; - -} - -double ParticleDeposit::getRecEnergy() const { - double energy(0); - for (std::vector::const_iterator cit = myRecDepositions.begin(); cit - != myRecDepositions.end(); ++cit) { - Deposition d = *cit; -// if (d.getDetectorElement()->getType() == OFFSET && d.getDetectorElement()->getCalib() == 1.0) { -// //don't add a tiny amount! -// } else { - energy += d.getDetectorElement()->getCalib(d.getEta(), d.getPhi()) * d.getEnergy(); -// } - } - - //assert(!(energy < 0)); - return energy; - -} - -double ParticleDeposit::getEnergyResolution() const { - //assert(!(getRecEnergy() / myTruthEnergy < 0.0)); - return fabs((getRecEnergy() - myTruthEnergy) / sqrt(myTruthEnergy)); -} - -double ParticleDeposit::getTargetFunctionContrib() const { - //assert(!(getRecEnergy() / myTruthEnergy < 0.0)); - return pow((getRecEnergy() - myTruthEnergy), 2); -} - -std::ostream& pftools::operator<<(std::ostream& s, const pftools::ParticleDeposit& p) { - s << "Particle id:\t" << p.getId() << ", \t trueEnergy: " << p.getTruthEnergy() << "\n"; - s.width(3); - s << "\tEta:\t" << p.getEta() << ",\tphi:\t" << p.getPhi() << "\n"; - for (std::vector::const_iterator cit = p.getRecDepositions().begin(); cit - != p.getRecDepositions().end(); ++cit) { - Deposition d = *cit; - DetectorElementPtr de(d.getDetectorElement()); - s << "\t" << *de << ": \t=> E_contrib = "; - s << de->getCalib(d.getEta(), d.getPhi()) * d.getEnergy() << "\n"; - } - s << "\tTotalRecEnergy: " << p.getRecEnergy() << ",\t res: " << p.getEnergyResolution() * 100 << "%\n"; - return s; -} diff --git a/RecoParticleFlow/PFClusterTools/src/SpaceManager.cc b/RecoParticleFlow/PFClusterTools/src/SpaceManager.cc deleted file mode 100644 index e0e97ac152505..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/SpaceManager.cc +++ /dev/null @@ -1,401 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/SpaceManager.h" -#include -#include -#include -#include "TROOT.h" -#include -#include "TH3F.h" -#include "TVirtualFitter.h" -#include "TProfile.h" -using namespace pftools; - -SpaceManager::SpaceManager(std::string name) : - name_(name), barrelLimit_(1.4), transitionLimit_(1.4), endcapLimit_(5.0) { - regionsToSVs_[BARREL_POS] = barrelPosRegion_; - regionsToSVs_[ENDCAP_POS] = endcapPosRegion_; -} - -SpaceManager::~SpaceManager() { - -} - -void SpaceManager::clear() { - for (std::map::iterator it = - myAddressBook.begin(); it!= myAddressBook.end(); ++it) { - SpaceVoxelPtr s = (*it).first; - CalibratorPtr c = (*it).second; - } -} - -void SpaceManager::createCalibrators(const Calibrator& toClone, - const double etaSeg, const double phiSeg, const double energySeg) { - std::cout << __PRETTY_FUNCTION__ - << ": this method has not yet been implemented!\n"; - PFToolsException me("Unimplemented method! Sorry!"); - throw me; - -} - -void SpaceManager::createCalibrators(const Calibrator& toClone) { - clear(); - std::cout << __PRETTY_FUNCTION__ - << ": creating default calibration schema.\n"; - - SpaceVoxelPtr sv(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 0, 3.0)); - barrelPosRegion_.push_back(sv); - SpaceVoxelPtr sv1(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 3, 9.0)); - barrelPosRegion_.push_back(sv1); - SpaceVoxelPtr sv2(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 9.0, 16.0)); - barrelPosRegion_.push_back(sv2); - SpaceVoxelPtr sv3(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 16.0, 25.0)); - barrelPosRegion_.push_back(sv3); - SpaceVoxelPtr sv4(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 25.0, 100.0)); - barrelPosRegion_.push_back(sv4); - SpaceVoxelPtr sv5(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 100.0, 200.0)); - barrelPosRegion_.push_back(sv5); - SpaceVoxelPtr sv6(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 200.0, 400.0)); - barrelPosRegion_.push_back(sv6); - - // SpaceVoxelPtr sv(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 0, 2.0)); - // barrelPosRegion_.push_back(sv); - // SpaceVoxelPtr sv1(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 1, 1.5)); - // barrelPosRegion_.push_back(sv1); - // SpaceVoxelPtr sv2(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 1.5, 2.0)); - // barrelPosRegion_.push_back(sv2); - // SpaceVoxelPtr sv3(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 2.0, 2.5)); - // barrelPosRegion_.push_back(sv3); - // SpaceVoxelPtr sv4(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 2.5, 4.0)); - // barrelPosRegion_.push_back(sv4); - // SpaceVoxelPtr sv41(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 4.0, 5.0)); - // barrelPosRegion_.push_back(sv41); - // SpaceVoxelPtr sv5(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 5.0, 6.5)); - // barrelPosRegion_.push_back(sv5); - // SpaceVoxelPtr sv51(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 6.5, 8.0)); - // barrelPosRegion_.push_back(sv51); - // SpaceVoxelPtr sv6(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 8.0, 10.0)); - // barrelPosRegion_.push_back(sv6); - // SpaceVoxelPtr sv61(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 10.0, 12.0)); - // barrelPosRegion_.push_back(sv61); - // SpaceVoxelPtr sv7(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 12.0, 16.0)); - // barrelPosRegion_.push_back(sv7); - // SpaceVoxelPtr sv8(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 16.0, 25.0)); - // barrelPosRegion_.push_back(sv8); - // SpaceVoxelPtr sv9(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 25.0, 40.0)); - // barrelPosRegion_.push_back(sv9); - // SpaceVoxelPtr sv10(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 40.0, 60.0)); - // barrelPosRegion_.push_back(sv10); - // SpaceVoxelPtr sv11(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 60.0, 100.0)); - // barrelPosRegion_.push_back(sv11); - // SpaceVoxelPtr sv12(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 100.0, 200.0)); - // barrelPosRegion_.push_back(sv12); - // SpaceVoxelPtr sv13(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 200.0, 400.0)); - // barrelPosRegion_.push_back(sv13); - - SpaceVoxelPtr sve(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0, 3.0)); - endcapPosRegion_.push_back(sve); - SpaceVoxelPtr sve0(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 3.0, 9.0)); - endcapPosRegion_.push_back(sve0); - SpaceVoxelPtr sve1(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 9.0, 16.0)); - endcapPosRegion_.push_back(sve1); - SpaceVoxelPtr sve2(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 16.0, 25.0)); - endcapPosRegion_.push_back(sve2); - SpaceVoxelPtr sve3(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 25.0, 100.0)); - endcapPosRegion_.push_back(sve3); - SpaceVoxelPtr sve4(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 100.0, 200.0)); - endcapPosRegion_.push_back(sve4); - SpaceVoxelPtr sve5(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 200.0, 400.0)); - endcapPosRegion_.push_back(sve5); - - // SpaceVoxelPtr sve(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0, 0.5)); - // endcapPosRegion_.push_back(sve); - // SpaceVoxelPtr sve0(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0.5, 1.0)); - // endcapPosRegion_.push_back(sve0); - // SpaceVoxelPtr sve1(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 1, 1.5)); - // endcapPosRegion_.push_back(sve1); - // SpaceVoxelPtr sve2(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 1.5, 2.0)); - // endcapPosRegion_.push_back(sve2); - // SpaceVoxelPtr sve3(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 2.0, 2.5)); - // endcapPosRegion_.push_back(sve3); - // SpaceVoxelPtr sve4(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 2.5, 4.0)); - // endcapPosRegion_.push_back(sve4); - // SpaceVoxelPtr sve5(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 4.0, 5.0)); - // endcapPosRegion_.push_back(sve5); - // SpaceVoxelPtr sve51(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 5.0, 6.5)); - // endcapPosRegion_.push_back(sve51); - // SpaceVoxelPtr sve6(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 6.5, 8.0)); - // endcapPosRegion_.push_back(sve6); - // SpaceVoxelPtr sve61(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 8.0, 10.0)); - // endcapPosRegion_.push_back(sve61); - // SpaceVoxelPtr sve62(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 10.0, 12.0)); - // endcapPosRegion_.push_back(sve62); - // SpaceVoxelPtr sve7(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 12.0, 16.0)); - // endcapPosRegion_.push_back(sve7); - // SpaceVoxelPtr sve8(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 16.0, 25.0)); - // endcapPosRegion_.push_back(sve8); - // SpaceVoxelPtr sve9(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 25.0, 40.0)); - // endcapPosRegion_.push_back(sve9); - // SpaceVoxelPtr sve10(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 40.0, 60.0)); - // endcapPosRegion_.push_back(sve10); - // SpaceVoxelPtr sve11(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 60.0, 100.0)); - // endcapPosRegion_.push_back(sve11); - // SpaceVoxelPtr sve12(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 100.0, 200.0)); - // endcapPosRegion_.push_back(sve12); - // SpaceVoxelPtr sve13(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 200.0, 400.0)); - // endcapPosRegion_.push_back(sve13); - - for (std::vector::iterator it = barrelPosRegion_.begin(); it - != barrelPosRegion_.end(); ++it) { - myKnownSpaceVoxels.push_back(*it); - } - - for (std::vector::iterator it = endcapPosRegion_.begin(); it - != endcapPosRegion_.end(); ++it) { - myKnownSpaceVoxels.push_back(*it); - } - - for (std::vector::iterator it = myKnownSpaceVoxels.begin(); it - != myKnownSpaceVoxels.end(); ++it) { - CalibratorPtr c(toClone.clone()); - myAddressBook[*it] = c; - } - std::cout << "Address book size: \t\t"<< myAddressBook.size() << "\n"; - std::cout << "Known space voxels size: \t"<< myKnownSpaceVoxels.size() - << "\n"; - assert(myAddressBook.size() == myKnownSpaceVoxels.size()); - -} - -void SpaceManager::createCalibrators(const Calibrator& toClone, - const unsigned nEta, const double etaMin, const double etaMax, - const unsigned nPhi, const double phiMin, const double phiMax, - const unsigned nEnergy, const double energyMin, const double energyMax) - noexcept(false) { - clear(); - - if (nEta == 0|| nPhi ==0|| nEnergy == 0) { - PFToolsException - me("Can't create calibrators with zero values for nEta, nPhi or nEnergy!"); - throw me; - } - - double etaSeg = (etaMax - etaMin) / nEta; - double phiSeg = (phiMax - phiMin) / nPhi; - double energySeg = (energyMax - energyMin) / nEnergy; - - double eta1, eta2, phi1, phi2, energy1, energy2; - for (unsigned k(0); k < nEta; ++k) { - for (unsigned l(0); l < nPhi; ++l) { - for (unsigned m(0); m < nEnergy; ++m) { - eta1 = etaMin + k * etaSeg; - eta2 = eta1 + etaSeg; - - phi1 = phiMin + l * phiSeg; - phi2 = phi1 + phiSeg; - - energy1 = energyMin + m * energySeg; - energy2 = energy1 + energySeg; - SpaceVoxelPtr sv(new SpaceVoxel(eta1, eta2, phi1, phi2, energy1, energy2)); - myKnownSpaceVoxels.push_back(sv); - CalibratorPtr c(toClone.clone()); - myAddressBook[sv] = c; - } - } - } - unsigned nCalibrators = nEta * nPhi * nEnergy; - std::cout << "Created "<< nCalibrators << " calibrators.\n"; - std::cout << "Address book size: \t\t"<< myAddressBook.size() << "\n"; - std::cout << "Known space voxels size: \t"<< myKnownSpaceVoxels.size() - << "\n"; - assert(myAddressBook.size() == myKnownSpaceVoxels.size()); - makeInverseAddressBook(); - -} -CalibratorPtr SpaceManager::createCalibrator(const Calibrator& toClone, - SpaceVoxelPtr s) { - CalibratorPtr c; - int known = count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s); - if (known == 0) { - myKnownSpaceVoxels.push_back(s); - c.reset(toClone.clone()); - myAddressBook[s] = c; - } else { - c = myAddressBook[s]; - } - assert(c != nullptr); - return c; - -} - -CalibratorPtr SpaceManager::findCalibrator(const double eta, const double phi, - const double energy) const { - CalibratorPtr answer; - for (std::vector::const_iterator cit = - myKnownSpaceVoxels.begin(); cit != myKnownSpaceVoxels.end(); ++cit) { - SpaceVoxelPtr s = *cit; - if (s->contains(eta, phi, energy)) { - assert(count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s) != 0); - answer = (*myAddressBook.find(s)).second; - break; - } else { - //assert(count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s) == 0); - } - } - return answer; -} - -void SpaceManager::assignCalibration(const CalibratorPtr& c, - const std::map& result) { - calibrationCoeffs_[c] = result; - makeInverseAddressBook(); -} - -std::map SpaceManager::getCalibration(CalibratorPtr c) { - return calibrationCoeffs_[c]; -} - -TH1* SpaceManager::extractEvolution(DetectorElementPtr det, Region r, TF1& f1, - bool useTruth) { - - std::vector region; - if (r == BARREL_POS) - region = barrelPosRegion_; - if (r == ENDCAP_POS) - region = endcapPosRegion_; - //region = regionsToSVs_[r]; - - std::sort(region.begin(), region.end(), SpaceVoxel()); - - std::string detElName = DetElNames[det->getType()]; - std::string name("hDist_"); - name.append(RegionNames[r]); - name.append("_"); - name.append(DetElNames[det->getType()]); - - double minE(1000); - double maxE(0); - - TH2F hDist(name.c_str(), name.c_str(), 100, 0, 300, 50, 0.0, 2.5); - // TH3F hSurf(nameSurf.c_str(), nameSurf.c_str(), 30, 0, 50, 10, 0.0, 3.0, 30, - // 0.0, 2.5); - for (std::vector::iterator i = region.begin(); i - != region.end(); ++i) { - SpaceVoxelPtr s = *i; - //double midE = (s->maxEnergy() + s->minEnergy()) / 2.0; - if (s->maxEnergy() > maxE) - maxE = s->maxEnergy(); - if (s->minEnergy() < minE) - minE = s->minEnergy(); - CalibratorPtr c = myAddressBook[s]; - double coeff = calibrationCoeffs_[c][det]; - if (coeff != 0.0) { - std::vector particles = c->getParticles(); - for (std::vector::iterator it = - particles.begin(); it != particles.end(); ++it) { - if (useTruth) - hDist.Fill((*it)->getTruthEnergy(), coeff); - else - hDist.Fill((*it)->getRecEnergy(), coeff); - } - } - } - - hDist.FitSlicesY(); - hDist.ProfileX(); - hDist.Write(); - std::string nameProfile(name); - nameProfile.append("_pfx"); - name.append("_1"); - - TH1D* slices = (TH1D*) gDirectory->Get(name.c_str()); - //TH2D* slicesSurf = (TH2D*) gDirectory->Get(nameSurf.c_str()); - TProfile* profile = (TProfile*) gDirectory->Get(nameProfile.c_str()); - profile->Fit(&f1); - slices->Fit(&f1); - profile->Write(); - - return slices; - -} - -double SpaceManager::evolveCoefficient(DetectorElementPtr det, double energy, - double eta, double phi) { - if (eta < barrelLimit_) { - TF1& func = barrelPosEvolutions_[det]; - return func.Eval(energy); - } - TF1& func = endcapPosEvolutions_[det]; - return func.Eval(energy); -} - -double SpaceManager::interpolateCoefficient(DetectorElementPtr det, - double energy, double eta, double phi) { - CalibratorPtr c = findCalibrator(eta, phi, energy); - - SpaceVoxelPtr s = inverseAddressBook_[c]; - - double midEnergy = (s->minEnergy() + s->maxEnergy())/2.0; - //interpolate left or right? - double diffEnergy = energy - midEnergy; - double thisCoeff = calibrationCoeffs_[c][det]; - - double interpolatedCoeff = thisCoeff; - double adjacentCoeff = 0.0; - double adjacentEnergy = 0.0; - if (diffEnergy > 0) { - //look to higher energy calibrators - CalibratorPtr adjC = findCalibrator(eta, phi, s->maxEnergy() + 0.1); - if (adjC != nullptr) { - SpaceVoxelPtr adjS = inverseAddressBook_[adjC]; - adjacentCoeff = calibrationCoeffs_[adjC][det]; - adjacentEnergy = (adjS->minEnergy() + adjS->maxEnergy()) / 2.0; - } - } else { - //look to lower energy calibrations - CalibratorPtr adjC = findCalibrator(eta, phi, s->minEnergy() - 0.1); - if (adjC != nullptr) { - SpaceVoxelPtr adjS = inverseAddressBook_[adjC]; - adjacentCoeff = calibrationCoeffs_[adjC][det]; - adjacentEnergy = (adjS->minEnergy() + adjS->maxEnergy()) / 2.0; - } - } - if (adjacentCoeff != 0) { - interpolatedCoeff = thisCoeff + diffEnergy* (adjacentCoeff - thisCoeff) - / (adjacentEnergy - midEnergy); - } - return interpolatedCoeff; -} - -std::ostream& SpaceManager::printCalibrations(std::ostream& stream) { - stream << "Calibration results: \n"; - // std::sort(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), - // SpaceVoxel()); - stream << "WARNING! Haven't sorted space voxels properly!\n"; - for (std::vector::iterator it = myKnownSpaceVoxels.begin(); it - != myKnownSpaceVoxels.end(); ++it) { - SpaceVoxelPtr s = *it; - CalibratorPtr c = myAddressBook[s]; - stream << *s << "\n"; - stream << "\t["; - std::map result = calibrationCoeffs_[c]; - for (std::map::iterator b = result.begin(); b - != result.end(); ++b) { - DetectorElementPtr d = (*b).first; - stream << *d << ": "; - double ans = (*b).second; - stream << ans << ", "; - } - stream << "]\n"; - } - - return stream; -} - -void SpaceManager::makeInverseAddressBook() { - inverseAddressBook_.clear(); - for (std::map::iterator it = - myAddressBook.begin(); it != myAddressBook.end(); ++it) { - SpaceVoxelPtr s = (*it).first; - CalibratorPtr c = (*it).second; - inverseAddressBook_[c] = s; - } -} diff --git a/RecoParticleFlow/PFClusterTools/src/SpaceVoxel.cc b/RecoParticleFlow/PFClusterTools/src/SpaceVoxel.cc deleted file mode 100644 index cb61d739da6c4..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/SpaceVoxel.cc +++ /dev/null @@ -1,116 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h" -#include -#include "RecoParticleFlow/PFClusterTools/interface/ToString.h" -using namespace pftools; - -SpaceVoxel::SpaceVoxel(double etaBegin, double etaEnd, double phiBegin, - double phiEnd, double energyBegin, double energyEnd, bool ecalValid, bool hcalValid) : - myEtaMin(etaBegin), myEtaMax(etaEnd), myPhiMin(phiBegin), myPhiMax(phiEnd), - myEnergyMin(energyBegin), myEnergyMax(energyEnd), - ecalValid_(ecalValid), hcalValid_(hcalValid) { - if (!ecalValid_ && !hcalValid_) { - //erm, it has to be valid for one of them at least! - std::cout << __PRETTY_FUNCTION__ - << ": WARNING! Constructed with both ecalValid and hcalValid = false!" - << std::endl; - } -} - -SpaceVoxel::~SpaceVoxel() { -} - -bool SpaceVoxel::contains(const double& eta, const double& phi, - const double& energy) const { - if (containsEta(eta) && containsPhi(phi) && containsEnergy(energy)) - return true; - return false; -} - -bool SpaceVoxel::contains(const double& eta, const double& phi, - const double& energy, const bool& ecalValid, const bool& hcalValid) const { - if (contains(eta, phi, energy) && ecalValid == ecalValid_ && hcalValid - == hcalValid_) - return true; - return false; -} - -bool SpaceVoxel::containsEta(const double& eta) const { - if (myEtaMin == myEtaMax) - return true; - if (eta < myEtaMax && eta >= myEtaMin) - return true; - //::cout << "\teta fails!\n"; - return false; -} - -bool SpaceVoxel::containsPhi(const double& phi) const { - if (myPhiMin == myPhiMax) - return true; - if (phi < myPhiMax && phi >= myPhiMin) - return true; - //std::cout << "\tphi fails!\n"; - return false; - -} - -bool SpaceVoxel::containsEnergy(const double& energy) const { - if (myEnergyMin == myEnergyMax) - return true; - if (energy < myEnergyMax && energy >= myEnergyMin) - return true; - //std::cout << "\tenergy fails!: input " << energy << " not in " << myEnergyMin << ", " << myEnergyMax <<"\n"; - return false; -} - -void SpaceVoxel::print(std::ostream& s) const { - s << "SpaceVoxel: "; - if (ecalValid_) - s << "E"; - if (hcalValid_) - s << "H, "; - s << "eta: ["<< myEtaMin << ", "<< myEtaMax << "]\t phi: ["<< myPhiMin - << ". "<< myPhiMax << "]\t energy: ["<< myEnergyMin<< ", " - << myEnergyMax << "]"; -} - -void SpaceVoxel::getName(std::string& s) const { - s.append("SpaceVoxel: "); - if (ecalValid_) - s.append("E"); - if (hcalValid_) - s.append("H"); - s.append(", eta: ["); - s.append(toString(myEtaMin)); - s.append(", "); - s.append(toString(myEtaMax)); - s.append("] phi: ["); - s.append(toString(myPhiMin)); - s.append(", "); - s.append(toString(myPhiMax)); - s.append("], en: ["); - s.append(toString(myEnergyMin)); - s.append(", "); - s.append(toString(myEnergyMax)); - s.append("]"); -} - -bool SpaceVoxel::operator()(const SpaceVoxel& sv1, const SpaceVoxel& sv2) { - if(sv1.minEnergy() < sv2.maxEnergy()) - return true; - - return false; -} - -bool SpaceVoxel::operator()(const SpaceVoxelPtr& svp1, const SpaceVoxelPtr& svp2) { - SpaceVoxel sv1 = *svp1; - SpaceVoxel sv2 = *svp2; - if(sv1.minEnergy() < sv2.maxEnergy()) - return true; - - return false; -} - -std::ostream& pftools::operator<<(std::ostream& s, const pftools::SpaceVoxel& sv) { - sv.print(s); - return s; -} diff --git a/RecoParticleFlow/PFClusterTools/src/TreeUtility.cc b/RecoParticleFlow/PFClusterTools/src/TreeUtility.cc deleted file mode 100644 index 0ec9743a70139..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/TreeUtility.cc +++ /dev/null @@ -1,354 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/TreeUtility.h" -#include "TBranch.h" -#include "TTree.h" -#include "DataFormats/ParticleFlowReco/interface/Calibratable.h" -#include -#include -#include -#include - -using namespace pftools; -TreeUtility::TreeUtility() { -} - -TreeUtility::~TreeUtility() { -} - -double deltaR(double eta1, double eta2, double phi1, double phi2) { - return sqrt(pow(eta1 - eta2, 2) + pow(phi1 - phi2, 2)); -} - -unsigned TreeUtility::getCalibratablesFromRootFile(TChain& tree, - std::vector& toBeFilled) { - - // f.cd("extraction"); - // TTree* tree = (TTree*) f.Get("extraction/Extraction"); - // if (tree == 0) { - // PFToolsException me("Couldn't open tree!"); - // throw me; - // } - // std::cout << "Successfully opened file. Getting branches..."<< std::endl; - CalibratablePtr calib_ptr(new Calibratable()); - //TBranch* calibBr = tree.GetBranch("Calibratable"); - //spwBr->SetAddress(&spw); - tree.SetBranchAddress("Calibratable", &calib_ptr); - - std::cout << "Looping over tree's "<< tree.GetEntries() << " entries...\n"; - for (unsigned entries(0); entries < tree.GetEntries(); entries++) { - tree.GetEntry(entries); - Calibratable c(*calib_ptr); - if (c.cands_num_ == 1 && (c.cluster_ecal_.size() + c.cluster_hcal_.size()) > 0) - toBeFilled.push_back(c); - } - std::cout << "Done." << std::endl; - return tree.GetEntries(); - -} - -void TreeUtility::dumpCaloDataToCSV(TChain& tree, std::string csvFilename, double range, bool gaus) { - - CalibratablePtr calib_ptr(new Calibratable()); - - tree.SetBranchAddress("Calibratable", &calib_ptr); - std::ofstream csvFile; - csvFile.open(csvFilename.c_str()); - - std::cout << "Looping over tree's "<< tree.GetEntries() << " entries...\n"; - unsigned writes(0); - TFile freq("freq.root", "recreate"); - TH1F frequencies("f", "f", 50, 0, range); - TF1 g("g", "gaus(0)"); - g.FixParameter(1, range/2.0); - g.FixParameter(0, 1), - g.FixParameter(2, range/4.0); - - for (unsigned entries(0); entries < tree.GetEntries(); entries++) { - tree.GetEntry(entries); - Calibratable c(*calib_ptr); - bool veto(false); - - //Check vetos as usual - if (c.cands_num_ > 1) - veto = true; - if(c.cluster_ecal_.empty() && c.cluster_hcal_.empty()) - veto = true; - if(!veto) { - if(frequencies.GetBinContent(static_cast(floor(c.sim_energyEvent_)) + 1) < (3000) * g.Eval(c.sim_energyEvent_) ) { - frequencies.Fill(static_cast(floor(c.sim_energyEvent_))); - c.recompute(); - csvFile << c.sim_energyEvent_ << "\t"; - /* - csvFile << c.sim_energyEcal_ << "\t"; - csvFile << c.sim_energyHcal_ << "\t"; - - - csvFile << c.cluster_energyEcal_/range << "\t"; - csvFile << c.cluster_energyHcal_/range << "\t"; - - CaloWindow newEcalWindow(c.cluster_meanEcal_.eta_, c.cluster_meanEcal_.phi_, 5, 0.01, 3); - const std::vector& ecal = c.cluster_ecal_; - std::vector::const_iterator cit = ecal.begin(); - for(; cit != ecal.end(); ++cit) { - const CalibratableElement& hit = *cit; - bool added = newEcalWindow.addHit(hit.eta_, hit.phi_, hit.energy_); - if(!added) - veto = true; - } - */ - - csvFile << fabs(c.sim_eta_/2) << "\n"; - - ++writes; - } - } - - - } - frequencies.Print("frequencies.eps"); - frequencies.Write(); - freq.Close(); - std::cout << "Closing file " << csvFilename << " with " << writes << " entries.\n" << std::endl; - - csvFile.close(); - -} - -unsigned TreeUtility::getParticleDepositsDirectly(TChain& sourceChain, - std::vector& toBeFilled, CalibrationTarget target, - DetectorElementPtr offset, DetectorElementPtr ecal, - DetectorElementPtr hcal, bool includeOffset) { - - CalibratablePtr calib_ptr(new Calibratable()); - sourceChain.SetBranchAddress("Calibratable", &calib_ptr); - std::cout << __PRETTY_FUNCTION__ << std::endl; - std::cout << "WARNING: Using fabs() for eta value assignments!\n"; - std::cout << "Cutting on > 1 PFCandidate.\n"; - std::cout << "Looping over tree's "<< sourceChain.GetEntries() << " entries...\n"; - //neither of these two are supported yet - if (target == UNDEFINED || target == PFELEMENT) - return 0; - unsigned count(0); - - for (unsigned entries(0); entries < sourceChain.GetEntries(); entries++) { - sourceChain.GetEntry(entries); - Calibratable c(*calib_ptr); - - ParticleDepositPtr pd(new ParticleDeposit()); - bool veto(false); - if (c.sim_isMC_) { - pd->setTruthEnergy(c.sim_energyEvent_); - pd->setEta(fabs(c.sim_eta_)); - pd->setPhi(c.sim_phi_); - //TODO:: sort this out - if (c.sim_energyEvent_== 0) - veto = true; - } - if (c.tb_isTB_) { - pd->setTruthEnergy(c.sim_energyEvent_); - pd->setEta(c.tb_eta_); - pd->setPhi(c.tb_phi_); - veto = false; - } - - if (c.cands_num_ > 1) - veto = true; - - std::cout << "WARNING: HARD CUT ON 100 GeV SIM PARTICLES!\n"; - if(c.sim_energyEvent_ > 100) - veto = true; - - if (target == CLUSTER) { - if (c.cluster_ecal_.empty() && c.cluster_hcal_.empty()) - veto = true; - // if (c.cluster_numEcal_ > 1|| c.cluster_numHcal_ > 1) - // veto = true; - //TODO: using fabs for eta! WARNING!!! - Deposition decal(ecal, fabs(c.cluster_meanEcal_.eta_), - c.cluster_meanEcal_.phi_, c.cluster_energyEcal_, 0); - Deposition dhcal(hcal, fabs(c.cluster_meanHcal_.eta_), - c.cluster_meanHcal_.phi_, c.cluster_energyHcal_, 0); - Deposition doffset(offset, fabs(c.cluster_meanEcal_.eta_), - c.cluster_meanEcal_.phi_, 0.001, 0); - - pd->addTruthDeposition(decal); - pd->addRecDeposition(decal); - - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - - } - - else if (target == PFCANDIDATE) { - // if(c.cands_num_ != 1) - // veto = true; - Deposition decal(ecal, c.cand_eta_, c.cand_phi_, - c.cand_energyEcal_, 0); - Deposition dhcal(hcal, c.cand_eta_, c.cand_phi_, - c.cand_energyHcal_, 0); - Deposition doffset(offset, c.cand_eta_, c.cand_phi_, 1.0, 0); - - pd->addTruthDeposition(decal); - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(decal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - } - - else if (target == RECHIT) { - if (c.rechits_ecal_.empty()&& c.rechits_hcal_.empty()) - veto = true; - Deposition decal(ecal, c.rechits_meanEcal_.eta_, - c.rechits_meanEcal_.phi_, c.rechits_meanEcal_.energy_ - * c.rechits_ecal_.size(), 0); - Deposition dhcal(hcal, c.rechits_meanHcal_.eta_, - c.rechits_meanHcal_.phi_, c.rechits_meanHcal_.energy_ - * c.rechits_hcal_.size(), 0); - Deposition doffset(offset, c.rechits_meanEcal_.eta_, - c.rechits_meanEcal_.phi_, 1.0, 0); - - pd->addTruthDeposition(decal); - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(decal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - - } - if (!veto) - toBeFilled.push_back(pd); - - ++count; - } - - return toBeFilled.size(); -} - -unsigned TreeUtility::convertCalibratablesToParticleDeposits( - const std::vector& input, - std::vector& toBeFilled, CalibrationTarget target, - DetectorElementPtr offset, DetectorElementPtr ecal, - DetectorElementPtr hcal, bool includeOffset) { - - std::cout << __PRETTY_FUNCTION__ << std::endl; - std::cout << "WARNING: Using fabs() for eta value assignments!\n"; - std::cout << "Input Calibratable has size "<< input.size() << "\n"; - std::cout << "Cutting on > 1 PFCandidate.\n"; - - //neither of these two are supported yet - if (target == UNDEFINED || target == PFELEMENT) - return 0; - unsigned count(0); - for (std::vector::const_iterator cit = input.begin(); cit - != input.end(); ++cit) { - Calibratable c = *cit; - ParticleDepositPtr pd(new ParticleDeposit()); - bool veto(false); - if (c.sim_isMC_) { - pd->setTruthEnergy(c.sim_energyEvent_); - pd->setEta(fabs(c.sim_eta_)); - pd->setPhi(c.sim_phi_); - //TODO:: sort this out - if (c.sim_energyEvent_== 0) - veto = true; - } - if (c.tb_isTB_) { - pd->setTruthEnergy(c.sim_energyEvent_); - pd->setEta(c.tb_eta_); - pd->setPhi(c.tb_phi_); - veto = false; - } - - if (c.cands_num_ > 1) - veto = true; - - if (target == CLUSTER) { - if (c.cluster_ecal_.empty()&& c.cluster_hcal_.empty()) - veto = true; - // if (c.cluster_numEcal_ > 1|| c.cluster_numHcal_ > 1) - // veto = true; - //TODO: using fabs for eta! WARNING!!! - Deposition decal(ecal, fabs(c.cluster_meanEcal_.eta_), - c.cluster_meanEcal_.phi_, c.cluster_energyEcal_, 0); - Deposition dhcal(hcal, fabs(c.cluster_meanHcal_.eta_), - c.cluster_meanHcal_.phi_, c.cluster_energyHcal_, 0); - Deposition doffset(offset, fabs(c.cluster_meanEcal_.eta_), - c.cluster_meanEcal_.phi_, 0.001, 0); - - pd->addTruthDeposition(decal); - pd->addRecDeposition(decal); - - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - - } - - else if (target == PFCANDIDATE) { - // if(c.cands_num_ != 1) - // veto = true; - Deposition decal(ecal, c.cand_eta_, c.cand_phi_, - c.cand_energyEcal_, 0); - Deposition dhcal(hcal, c.cand_eta_, c.cand_phi_, - c.cand_energyHcal_, 0); - Deposition doffset(offset, c.cand_eta_, c.cand_phi_, 1.0, 0); - - pd->addTruthDeposition(decal); - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(decal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - } - - else if (target == RECHIT) { - if (c.rechits_ecal_.empty()&& c.rechits_hcal_.empty()) - veto = true; - Deposition decal(ecal, c.rechits_meanEcal_.eta_, - c.rechits_meanEcal_.phi_, c.rechits_meanEcal_.energy_ - * c.rechits_ecal_.size(), 0); - Deposition dhcal(hcal, c.rechits_meanHcal_.eta_, - c.rechits_meanHcal_.phi_, c.rechits_meanHcal_.energy_ - * c.rechits_hcal_.size(), 0); - Deposition doffset(offset, c.rechits_meanEcal_.eta_, - c.rechits_meanEcal_.phi_, 1.0, 0); - - pd->addTruthDeposition(decal); - pd->addTruthDeposition(dhcal); - pd->addRecDeposition(decal); - pd->addRecDeposition(dhcal); - - if (includeOffset) { - pd->addTruthDeposition(doffset); - pd->addRecDeposition(doffset); - } - - } - if (!veto) - toBeFilled.push_back(pd); - - ++count; - } - - return toBeFilled.size(); - -} - diff --git a/RecoParticleFlow/PFClusterTools/src/Utils.cc b/RecoParticleFlow/PFClusterTools/src/Utils.cc deleted file mode 100644 index f1db22839a3e9..0000000000000 --- a/RecoParticleFlow/PFClusterTools/src/Utils.cc +++ /dev/null @@ -1,83 +0,0 @@ -#include "RecoParticleFlow/PFClusterTools/interface/Utils.h" - -#include -#include -#include -#include - -#include "TCanvas.h" -#include "TVector3.h" - -using namespace std; -using namespace pftools; -bool Utils::StringMatch(const char* str, const char* pattern) { - int status; - regex_t re; - - if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 ) - return false; - - status = regexec(&re, str, (size_t)0, nullptr, 0); - regfree(&re); - - if (status != 0) - return false; - - return true; -} - - -TCanvas* Utils::DivideCanvas( TCanvas *cv, int nPads ) { - if( !cv ) return nullptr; - - if( nPads<=1 ) return cv; - int sqnP = (unsigned int) (sqrt( nPads )); - int nC = sqnP; - int nL = sqnP; - - while( nC*nL < nPads ) - if( nC < nL ) nC++; - else nL++; - - cv->Divide( nC, nL, 0.005, 0.005, 0 ); - return cv; -} - -vector Utils::Glob(const char* pattern) { - - glob_t globbuf; - - globbuf.gl_offs = 2; - glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, nullptr, &globbuf); - - vector results; - for(unsigned i=0; i - - - - - - - - - - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterTools/test/BuildFile.xml b/RecoParticleFlow/PFClusterTools/test/BuildFile.xml deleted file mode 100644 index 3aa42b5339e1f..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/BuildFile.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibration.py b/RecoParticleFlow/PFClusterTools/test/ProducePFCalibration.py deleted file mode 100644 index bfc051ec5ce54..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibration.py +++ /dev/null @@ -1,151 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("myprocess") -#process.load("CondCore.DBCommon.CondDBCommon_cfi") -process.load("CondCore.CondDB.CondDB_cfi") -#process.CondDBCommon.connect = 'sqlite_file:PhysicsPerformance.db' - - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1) -) -process.source = cms.Source("EmptySource", - firstRun = cms.untracked.uint32(10) - ) - -# process.PoolDBOutputService.DBParameters.messageLevel = 3 - - -process.mywriter = cms.EDAnalyzer( - "ProducePFCalibrationObject", - write = cms.untracked.bool(False), - toWrite = cms.VPSet( - cms.PSet(fType = cms.untracked.string("PFfa_BARREL"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(-13.9219, 14.9124, 5.38578, 0.861981, -0.00759275, 0.00373563, -1.17946, -1.69561, ) - ), - cms.PSet(fType = cms.untracked.string("PFfb_BARREL"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(2.25366, 0.537715, -4.81375, 12.109, 1.80577, 0.187919, -6.26234, -0.607392, ) - ), - cms.PSet(fType = cms.untracked.string("PFfc_BARREL"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(1.5126, 0.855057, -6.04199, 2.08229, 0.592266, 0.0291232, 0.364802, -1.50142, ) - ), - cms.PSet(fType = cms.untracked.string("PFfaEta_BARRELEH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.0185555, -0.0470674, 396.959, ) - ), - cms.PSet(fType = cms.untracked.string("PFfbEta_BARRELEH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.0396458, 0.114128, 251.405, ) - ), - cms.PSet(fType = cms.untracked.string("PFfaEta_BARRELH"), - formula = cms.untracked.string("[0]+[1]*x"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.00434994, -5.16564e-06, ) - ), - cms.PSet(fType = cms.untracked.string("PFfbEta_BARRELH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(-0.0232604, 0.0937525, 34.9935, ) - ), - - cms.PSet(fType = cms.untracked.string("PFfa_ENDCAP"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.962468, 11.9536, -27.7088, 0.755474, 0.0791012, 0.0011082, 0.158734, -2.1, ) - ), - cms.PSet(fType = cms.untracked.string("PFfb_ENDCAP"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(-0.629923, 2.59634, -2.27786, 1.20771, -1.59129, 0.0189607, 0.270027, -2.30372, ) - ), - cms.PSet(fType = cms.untracked.string("PFfc_ENDCAP"), - formula = cms.untracked.string("[0]+((([1]+([2]/sqrt(x)))*exp(-(x^[6]/[3])))-([4]*exp(-(x^[7]/[5]))))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(1.83168, 1.41883, -5.50085, 29.2208, 0.923959, 0.268974, 1.37756, -0.901421, ) - ), - cms.PSet(fType = cms.untracked.string("PFfaEta_ENDCAPEH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(384.307, -384.305, 2.16374e+08, ) - ), - cms.PSet(fType = cms.untracked.string("PFfbEta_ENDCAPEH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.0120097, -0.131464, 57.1104, ) - ), - - cms.PSet(fType = cms.untracked.string("PFfaEta_ENDCAPH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])+[3]*[3]*exp(-x*x/([4]*[4]))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(-0.0106029, -0.692207, 0.0542991, -0.171435, -61.2277, ) - ), - cms.PSet(fType = cms.untracked.string("PFfbEta_ENDCAPH"), - formula = cms.untracked.string("[0]+[1]*exp(-x/[2])+[3]*[3]*exp(-x*x/([4]*[4]))"), - limits = cms.untracked.vdouble(1., 1000.), - parameters = cms.untracked.vdouble(0.0214894, -0.266704, 5.2112, 0.303578, -104.367, ) - ), - ), - - - read = cms.untracked.bool(True), - toRead = cms.untracked.vstring("PFfa_BARREL", - "PFfb_BARREL", - "PFfc_BARREL", - "PFfa_ENDCAP", - "PFfb_ENDCAP", - "PFfc_ENDCAP", - #### New Functions - "PFfaEta_BARRELEH", - "PFfbEta_BARRELEH", - "PFfaEta_ENDCAPEH", - "PFfbEta_ENDCAPEH", - "PFfaEta_BARRELH", - "PFfbEta_BARRELH", - "PFfaEta_ENDCAPH", - "PFfbEta_ENDCAPH", - #### Left older functions untouched for backward compatibility - "PFfaEta_BARREL", - "PFfbEta_BARREL", - "PFfaEta_ENDCAP", - "PFfbEta_ENDCAP", - - ) # same strings as fType -) - - -process.p = cms.Path(process.mywriter) - -from CondCore.DBCommon.CondDBCommon_cfi import CondDBCommon -CondDBCommon.connect = "sqlite_file:PFCalibration.db" - -process.PoolDBOutputService = cms.Service("PoolDBOutputService", - CondDBCommon, - toPut = cms.VPSet(cms.PSet(record = cms.string('PFCalibrationRcd'), - tag = cms.string('PFCalibration_v7_mc'), - timetype = cms.untracked.string('runnumber') - ) - ), - loadBlobStreamer = cms.untracked.bool(False), - # timetype = cms.untracked.string('lumiid') - # timetype = cms.untracked.string('runnumber') - ) - -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.GlobalTag.globaltag = '90X_upgrade2017_realistic_v20' -#process.GlobalTag.connect = 'sqlite_file:/afs/cern.ch/user/c/cerminar/public/Alca/GlobalTag/GR_R_311_V2.db' - -process.GlobalTag.toGet = cms.VPSet( - cms.PSet(record = cms.string("PFCalibrationRcd"), - tag = cms.string("PFCalibration_v7_mc"), - connect = cms.string("sqlite_file:PFCalibration.db") - #connect = cms.untracked.string("sqlite_file:PFCalibration.db") - ) - ) diff --git a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.cc b/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.cc deleted file mode 100644 index cd6091b7dac83..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.cc +++ /dev/null @@ -1,269 +0,0 @@ - -/* - * See header file for a description of this class. - * - * \author G. Cerminara - CERN - */ - -#include "ProducePFCalibrationObject.h" - -#include -#include -#include "CondFormats/PhysicsToolsObjects/interface/PerformancePayloadFromTFormula.h" -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" - -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -#include "CondFormats/DataRecord/interface/PFCalibrationRcd.h" - - -#include "TF1.h" - - -using namespace std; -using namespace edm; - -ProducePFCalibrationObject::ProducePFCalibrationObject(const edm::ParameterSet& pSet) { - - - read = pSet.getUntrackedParameter("read"); - write = pSet.getUntrackedParameter("write"); - - fToWrite = pSet.getParameter >("toWrite"); - fToRead = pSet.getUntrackedParameter >("toRead"); - -} - -ProducePFCalibrationObject::~ProducePFCalibrationObject(){} - - - - -// void ProducePFCalibrationObject::beginJob() { -void ProducePFCalibrationObject::beginRun(const edm::Run& run, const edm::EventSetup& eSetup) { - - cout << "[ProducePFCalibrationObject] beginJob" << endl; - - - - string record = "PFCalibrationRcd"; - - static map functType; - functType["PFfa_BARREL"] = PerformanceResult::PFfa_BARREL; - functType["PFfa_ENDCAP"] = PerformanceResult::PFfa_ENDCAP; - functType["PFfb_BARREL"] = PerformanceResult::PFfb_BARREL; - functType["PFfb_ENDCAP"] = PerformanceResult::PFfb_ENDCAP; - functType["PFfc_BARREL"] = PerformanceResult::PFfc_BARREL; - functType["PFfc_ENDCAP"] = PerformanceResult::PFfc_ENDCAP; - //New added functions for H/EH hadrons - functType["PFfaEta_BARRELH"] = PerformanceResult::PFfaEta_BARRELH; - functType["PFfaEta_ENDCAPH"] = PerformanceResult::PFfaEta_ENDCAPH; - functType["PFfbEta_BARRELH"] = PerformanceResult::PFfbEta_BARRELH; - functType["PFfbEta_ENDCAPH"] = PerformanceResult::PFfbEta_ENDCAPH; - functType["PFfaEta_BARRELEH"] = PerformanceResult::PFfaEta_BARRELEH; - functType["PFfaEta_ENDCAPEH"] = PerformanceResult::PFfaEta_ENDCAPEH; - functType["PFfbEta_BARRELEH"] = PerformanceResult::PFfbEta_BARRELEH; - functType["PFfbEta_ENDCAPEH"] = PerformanceResult::PFfbEta_ENDCAPEH; - //Left older functions untouched for backward compatibility - functType["PFfaEta_BARREL"] = PerformanceResult::PFfaEta_BARREL; - functType["PFfaEta_ENDCAP"] = PerformanceResult::PFfaEta_ENDCAP; - functType["PFfbEta_BARREL"] = PerformanceResult::PFfbEta_BARREL; - functType["PFfbEta_ENDCAP"] = PerformanceResult::PFfbEta_ENDCAP; - - - // --------------------------------------------------------------------------------- - // Write the payload - - - - if(write) { - - vector > limitsToWrite; - vector formulasToWrite; - vector resToWrite; - vector binsToWrite; - binsToWrite.push_back(BinningVariables::JetEt); - - - - // loop over all the pSets for the TF1 that we want to write to DB - for(vector::const_iterator fSetup = fToWrite.begin(); - fSetup != fToWrite.end(); - ++fSetup) { - - // read from cfg - string fType = (*fSetup).getUntrackedParameter("fType"); - //FIXME: should check that the give type exists - string formula = (*fSetup).getUntrackedParameter("formula"); - pair limits = make_pair((*fSetup).getUntrackedParameter >("limits")[0], - (*fSetup).getUntrackedParameter >("limits")[1]); - vector parameters = (*fSetup).getUntrackedParameter >("parameters"); - - TF1 *function = new TF1(fType.c_str(), formula.c_str(), limits.first, limits.second); - for(unsigned int index = 0; index != parameters.size(); ++index) { - function->SetParameter(index, parameters[index]); - } - - // write them in the containers for the storage - limitsToWrite.push_back(limits); - formulasToWrite.push_back(string(function->GetExpFormula("p").Data())); - resToWrite.push_back(functType[fType]); - - } - - - // create the actual object storing the functions - PhysicsTFormulaPayload allTFormulas(limitsToWrite, formulasToWrite); - - // put them in the container - PerformancePayloadFromTFormula * pfCalibrationFormulas = - new PerformancePayloadFromTFormula(resToWrite, - binsToWrite, - allTFormulas); - - - // actually write to DB - edm::Service dbOut; - if(dbOut.isAvailable()) { - dbOut->writeOne(pfCalibrationFormulas, 1, record); - } - - } - - - - - if(read) { - // --------------------------------------------------------------------------------- - // Read the objects - edm::ESHandle perfH; - eSetup.get().get(perfH); - - const PerformancePayloadFromTFormula *pfCalibrations = static_cast< const PerformancePayloadFromTFormula *>(perfH.product()); - - for(vector::const_iterator name = fToRead.begin(); - name != fToRead.end(); ++name) { - - - - cout << "Function: " << *name << endl; - PerformanceResult::ResultType fType = functType[*name]; - pfCalibrations->printFormula(fType); - - // evaluate it @ 10 GeV - float energy = 10.; - - BinningPointByMap point; - point.insert(BinningVariables::JetEt, energy); - - if(pfCalibrations->isInPayload(fType, point)) { - float value = pfCalibrations->getResult(fType, point); - cout << " Energy before:: " << energy << " after: " << value << endl; - } else cout << "outside limits!" << endl; - - } - } - /// if(pfCalibrationFormulas->isInPayload(etaBin, point)) { -// float value = pfCalibrationFormulas->getResult(etaBin, point); -// cout << "t: " << t << " eta: " << eta << " CalibObj: " << -// value << endl; -// } else cout << "INVALID result!!!" << endl; - - -// TF1* faBarrel = new TF1("faBarrel","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.); - -// faBarrel->SetParameter(0,1.10772); -// faBarrel->SetParameter(1,0.186273); -// faBarrel->SetParameter(2,-0.47812); -// faBarrel->SetParameter(3,62.5754); -// faBarrel->SetParameter(4,1.31965); -// faBarrel->SetParameter(5,35.2559); - -// // faBarrel->GetExpFormula("p").Data() -// TF1 * faEndcap = new TF1("faEndcap","[0]+([1]+[2]/sqrt(x))*exp(-x/[3])-[4]*exp(-x*x/[5])",1.,1000.); -// faEndcap->SetParameter(0,1.0877); -// faEndcap->SetParameter(1,0.28939); -// faEndcap->SetParameter(2,-0.57635); -// faEndcap->SetParameter(3,86.5501); -// faEndcap->SetParameter(4,1.02296); -// faEndcap->SetParameter(5,64.0116); - -// std::vector< std::pair > limits; -// limits.push_back(make_pair(0,99999999)); -// // limits.push_back(make_pair(0,1.48 )); - -// limits.push_back(make_pair(0,99999999)); -// // limits.push_back(make_pair(1.48,5)); - - - -// std::vector formulas; -// formulas.push_back(string(faBarrel->GetExpFormula("p").Data())); -// formulas.push_back(string(faEndcap->GetExpFormula("p").Data())); - -// std::vector res; -// res.push_back(PerformanceResult::PFfa_BARREL); -// res.push_back(PerformanceResult::PFfa_ENDCAP); - -// std::vector bin; -// bin.push_back(BinningVariables::JetEt); -// // bin.push_back(BinningVariables::JetAbsEta); - -// bin.push_back(BinningVariables::JetEt); -// // bin.push_back(BinningVariables::JetAbsEta); - - -// PhysicsTFormulaPayload ppl(limits, formulas); -// // PerformanceResult::PFfa_BARREL - -// PerformancePayloadFromTFormula * pfCalibrationFormulas = -// new PerformancePayloadFromTFormula(res, -// bin, -// ppl); - - -// double t = 10.; -// double eta = 2.1; - -// BinningPointByMap point; -// point.insert(BinningVariables::JetEt, t); -// //point.insert(BinningVariables::JetAbsEta, eta); - -// PerformanceResult::ResultType etaBin; - - -// if(fabs(eta) < 1.48 ) { -// // this is the barrel -// etaBin = PerformanceResult::PFfa_BARREL; -// cout << " f_barrel(a): " << faBarrel->Eval(t) << endl; - - -// } else { -// // this is the endcap -// etaBin = PerformanceResult::PFfa_BARREL; -// cout << " f_endcap(a): " << faEndcap->Eval(t) << endl; - -// // if(pfCalibrationFormulas->isInPayload(PerformanceResult::PFfa_ENDCAP, point)){ -// // float value = pfCalibrationFormulas->getResult(PerformanceResult::PFfa_ENDCAP, point); -// // cout << "t: " << t << " eta: " << eta << " f_endcap(a): " << faEndcap->Eval(t) << " CalibObj: " << -// // value << endl; -// // } else cout << "INVALID result!!!" << endl; -// } - -// if(pfCalibrationFormulas->isInPayload(etaBin, point)) { -// float value = pfCalibrationFormulas->getResult(etaBin, point); -// cout << "t: " << t << " eta: " << eta << " CalibObj: " << -// value << endl; -// } else cout << "INVALID result!!!" << endl; - - - - -} - - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(ProducePFCalibrationObject); diff --git a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.h b/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.h deleted file mode 100644 index ee7bc8a5a18bc..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/ProducePFCalibrationObject.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ProducePFCalibrationObject_H -#define ProducePFCalibrationObject_H - -/** \class ProducePFCalibrationObject - * No description available. - * - * \author G. Cerminara - CERN - */ -#include "FWCore/Framework/interface/EDAnalyzer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include -#include - -class ProducePFCalibrationObject : public edm::EDAnalyzer { -public: - /// Constructor - ProducePFCalibrationObject(const edm::ParameterSet&); - - /// Destructor - virtual ~ProducePFCalibrationObject(); - - // Operations -// virtual void beginJob(); - virtual void beginRun(const edm::Run& run, const edm::EventSetup& eSetup); - - virtual void analyze(const edm::Event&, const edm::EventSetup&) {} - virtual void endJob() {} - -protected: - -private: - - bool read; - bool write; - - std::vector fToWrite; - std::vector fToRead; - -}; -#endif - diff --git a/RecoParticleFlow/PFClusterTools/test/pfClusterTools.opt b/RecoParticleFlow/PFClusterTools/test/pfClusterTools.opt deleted file mode 100644 index b8149f20ea7d0..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/pfClusterTools.opt +++ /dev/null @@ -1,47 +0,0 @@ -//Options file for PFClusterTools - -//Include 'a' term when computing calibrations (leave as false; it doesn't work well). -exercises withOffset false -//How many particles required to create a calibration? -exercises threshold 5 - -exercises debug 5 - -//Apply corrections? -correction doCorrection 1 -correction doEtaCorrection 1 -//Bulk correction parameters -correction globalP0 -2.314808 -correction globalP1 1.01 -correction globalP2 0.0 -//Low energy correction parameters -correction correctionLowLimit 1.0 -correction lowEP0 3.249189e-01 -correction lowEP1 7.907990e-01 -correction allowNegativeEnergy 0 -correction maxEToCorrect -1.0 -correction mlpOffset 3.2 -correction mlpSlope 0.9 -//Auto fit evolution function to data -evolution autoFit 0 -evolution basePlots 0 -evolution basePlotsUseTruth 1 - -evolution ecalECut 0.0 -evolution hcalECut 0.0 -evolution barrelEndcapEtaDiv 1.4 - -//Use hand fitted parameters specified below -evolution ecalHcalEcalBarrel 0.67 3.0 1.15 0.90 -0.060 1.4 -evolution ecalHcalEcalEndcap 0.46 3.0 1.10 0.40 -0.020 1.4 -evolution ecalHcalHcalBarrel 0.46 3.0 1.15 0.30 -0.020 1.4 -evolution ecalHcalHcalEndcap 0.460 3.0 1.10 0.30 -0.02 1.4 -evolution etaCorrection 1.01 -1.02e-02 5.17e-02 0.563 -0.425 0.110 - - -//What kind of interpolation is used for evaluating particle energy -// 0 = none, 1 = simple bilinear, 2 = fitted function to truth, 3 fitted function to reco, 4 = magic! -spaceManager interpolationMode 4 - -//Creates a file, but this isn't used yet. -results calibParamOutput calibParams.txt diff --git a/RecoParticleFlow/PFClusterTools/test/pfClusterToolsTB.opt b/RecoParticleFlow/PFClusterTools/test/pfClusterToolsTB.opt deleted file mode 100644 index 1d3e1c08d696b..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/pfClusterToolsTB.opt +++ /dev/null @@ -1,46 +0,0 @@ -//Options file for PFClusterTools - -//Include 'a' term when computing calibrations (leave as false; it doesn't work well). -exercises withOffset false -//How many particles required to create a calibration? -exercises threshold 30 - -exercises debug 5 - -//Apply corrections? -correction doCorrection 1 -correction doEtaCorrection 1 -//Bulk correction parameters -correction globalP0 1.54 -correction globalP1 0.90 -correction globalP2 0.0 -//Low energy correction parameters -correction correctionLowLimit 1.0 -correction lowEP0 -1.98 -correction lowEP1 1.11 -correction allowNegativeEnergy 0 -correction maxEToCorrect -1.0 - -//Auto fit evolution function to data -evolution autoFit 0 -evolution basePlots 1 -evolution basePlotsUseTruth 1 - -evolution ecalECut 0.0 -evolution hcalECut 0.0 -evolution barrelEndcapEtaDiv 1.4 - -//Use hand fitted parameters specified below -evolution ecalHcalEcalBarrel 0.67 3.0 1.15 0.90 -0.035 1.7 -evolution ecalHcalEcalEndcap 0.11 10.0 1.10 0.00 0.00 1.7 -evolution ecalHcalHcalBarrel 0.46 3.0 1.10 0.30 -0.020 1.4 -evolution ecalHcalHcalEndcap 0.460 3.0 1.10 0.30 -0.02 1.4 -evolution etaCorrection 1.01 -1.02e-02 5.17e-02 0.563 -0.425 0.110 - - -//What kind of interpolation is used for evaluating particle energy -// 0 = none, 1 = simple bilinear, 2 = fitted function to truth, 3 fitted function to reco, 4 = magic! -spaceManager interpolationMode 4 - -//Creates a file, but this isn't used yet. -results calibParamOutput calibParams.txt diff --git a/RecoParticleFlow/PFClusterTools/test/pfClusterTools_fitToReco.opt.old b/RecoParticleFlow/PFClusterTools/test/pfClusterTools_fitToReco.opt.old deleted file mode 100644 index 444e36c42ec75..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/pfClusterTools_fitToReco.opt.old +++ /dev/null @@ -1,97 +0,0 @@ -//Options file for PFClusterTools -//Just for the record, this has all the old fit parameters, fitted to reco (rather than truth with scaling -//as used now. As such, it won't work out the box. -exercises withOffset false -exercises threshold 30 -exercises debug 5 - - -//Apply corrections? -correction doCorrection true -//Bulk correction parameters -correction globalP0 -1.271173 -//correction globalP1 9.553564e-01 -correction globalP1 1.004834 -correction globalP2 0.0 -//Low energy correction parameters -correction correctionLowLimit 10.0 -//correction lowEP0 -correction lowEP0 -1.271173 -correction lowEP1 9.553564e-01 -correction lowEP2 0.0 - -//How to split between ecalOnly, hcalOnly and ecalHcal -exercises ecalECut 0.5 -exercises hcalECut 0.5 - -//Auto fit evolution function to data -evolution autoFit 0 -evolution basePlots 1 - -//Use hand fitted parameters specified below -//P1 adjusts the height of the peak -evolution ecalOnlyP0Barrel -4.5 -evolution ecalOnlyP1Barrel -1.254 -evolution ecalOnlyP2Barrel 1.254 -evolution ecalOnlyP3Barrel 0.89 -evolution ecalOnlyP4Barrel 1.35 -evolution ecalOnlyP5Barrel 1.0 - -evolution ecalOnlyP0Endcap -6.225 -evolution ecalOnlyP1Endcap -2.272 -evolution ecalOnlyP2Endcap 2.272 -evolution ecalOnlyP3Endcap 0.797 -evolution ecalOnlyP4Endcap 1.3 -evolution ecalOnlyP5Endcap 1.0 - -evolution hcalOnlyP0Barrel -4.08 -evolution hcalOnlyP1Barrel -2.48 -evolution hcalOnlyP2Barrel 2.67 -evolution hcalOnlyP3Barrel 0.8045 -evolution hcalOnlyP4Barrel 1.25 -evolution hcalOnlyP5Barrel 1.0 - -evolution hcalOnlyP0Endcap -5.534 -evolution hcalOnlyP1Endcap -2.80 -evolution hcalOnlyP2Endcap 2.80 -evolution hcalOnlyP3Endcap 0.80 -evolution hcalOnlyP4Endcap 1.3 -evolution hcalOnlyP5Endcap 1.0 - -//this one needs special attention - viz P1! -evolution ecalHcalP0EcalBarrel -3.323 -evolution ecalHcalP1EcalBarrel -1.500 -evolution ecalHcalP2EcalBarrel 2.429 -evolution ecalHcalP3EcalBarrel 0.767 -evolution ecalHcalP4EcalBarrel 1.2 -evolution ecalHcalP5EcalBarrel 1.0 - -evolution ecalHcalP0EcalEndcap -6.078 -evolution ecalHcalP1EcalEndcap 0.4 -evolution ecalHcalP2EcalEndcap 3.0 -evolution ecalHcalP3EcalEndcap 0.73 -evolution ecalHcalP4EcalEndcap 1.15 -evolution ecalHcalP5EcalEndcap 1.0 - -evolution ecalHcalP0HcalBarrel -5.0 -evolution ecalHcalP1HcalBarrel 0.11 -evolution ecalHcalP2HcalBarrel 1.57 -evolution ecalHcalP3HcalBarrel 0.86 -evolution ecalHcalP4HcalBarrel 1.3 -evolution ecalHcalP5HcalBarrel 1.0 - -evolution ecalHcalP0HcalEndcap -6.06 -evolution ecalHcalP1HcalEndcap -3.7 -evolution ecalHcalP2HcalEndcap 3.7 -evolution ecalHcalP3HcalEndcap 0.94 -evolution ecalHcalP4HcalEndcap 1.5 -evolution ecalHcalP5HcalEndcap 1.0 - -evolution evolutionFunctionMinE 0.5 -evolution evolutionFunctionMaxE 30 - -//What kind of interpolation is used for evaluating particle energy -// 0 = none, 1 = simple bilinear, 2 = fitted function to truth, 3 fitted function to reco -spaceManager interpolationMode 4 - -results calibParamOutput calibParams.txt diff --git a/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrate.C b/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrate.C deleted file mode 100644 index 914bfd0bc9a10..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrate.C +++ /dev/null @@ -1,33 +0,0 @@ -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - - std::cout << "Constructing PFClusterCalibration..." << std::endl; - IO* io = new IO("pfClusterTools.opt"); - PFClusterCalibration cc(io); - TFile f("../../../UserCode/JamieBallin/test/DipionDelV2_famosPions_0to30GeV_threshApp_200k.root"); - - f.cd("extraction"); - TTree* tree = (TTree*) f.Get("extraction/Extraction"); - - if (tree == 0) { - PFToolsException me("Couldn't open tree!"); - throw me; - } - - std::cout << "Opening new file...\n"; - TFile output("NewCalibratables.root","recreate"); - std::cout << "Cloning tree..\n"; - TTree* newTree = tree->CloneTree(20000); - output.Add(newTree); - //f.close(); - std::cout << "Calibrating tree...\n"; - cc.calibrateTree(newTree); - std::cout << "Writing tree...\n"; - newTree->Write(); - output.Write(); - - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrationExample.C b/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrationExample.C deleted file mode 100644 index ba83df2abda93..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/clusterCalibrationExample.C +++ /dev/null @@ -1,45 +0,0 @@ - -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - - - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - std::cout << "Constructing IO..." << std::endl; - - IO* options_ = new IO("pfClusterTools.opt"); - - PFClusterCalibration clusterCalibration_; - - //Initialise function parameters properly. - double g0, g1, e0, e1; - options_->GetOpt("correction", "globalP0", g0); - options_->GetOpt("correction", "globalP1", g1); - options_->GetOpt("correction", "lowEP0", e0); - options_->GetOpt("correction", "lowEP1", e1); - clusterCalibration_.setCorrections(e0, e1, g0, g1); - - int allowNegative(0); - options_->GetOpt("correction", "allowNegativeEnergy", allowNegative); - clusterCalibration_.setAllowNegativeEnergy(allowNegative); - - int doCorrection(1); - options_->GetOpt("correction", "doCorrection", doCorrection); - clusterCalibration_.setDoCorrection(doCorrection); - - double barrelEta; - options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEta); - clusterCalibration_.setBarrelBoundary(barrelEta); - - std::vector* names = clusterCalibration_.getKnownSectorNames(); - for(std::vector::iterator i = names->begin(); i != names->end(); ++i) { - std::string sector = *i; - std::vector params; - options_->GetOpt("evolution", sector.c_str(), params); - clusterCalibration_.setEvolutionParameters(sector, params); - } - - std::cout << clusterCalibration_ << "\n"; - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/compareCalib.C b/RecoParticleFlow/PFClusterTools/test/src/compareCalib.C deleted file mode 100644 index 73a5a90e8105c..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/compareCalib.C +++ /dev/null @@ -1,20 +0,0 @@ - -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - - std::cout << "Constructing CalibCompare..." << std::endl; - - IO* io = new IO("pfClusterTools.opt"); - CalibCompare* cc = new CalibCompare(io); - std::cout << "Constructed exercises and options, calibrating...\n"; - TChain c("extraction/Extraction"); - //c.Add("/castor/cern.ch/user/b/ballin/DipionDelV2_famosPions_0to300GeV_threshApp_200k.root"); - //c.Add("/castor/cern.ch/user/b/ballin/DipionDelV2_famosPions_0to30GeV_threshApp_200k.root"); - c.Add("/castor/cern.ch/user/b/ballin/DipionDelegate_50GeV_BarrelOnly_100k_2_1_11.root"); - - cc->calibrateCalibratables(c, "CalibCompare2.root"); - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/doCalib.C b/RecoParticleFlow/PFClusterTools/test/src/doCalib.C deleted file mode 100644 index 056b7164c85dd..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/doCalib.C +++ /dev/null @@ -1,25 +0,0 @@ - -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - - std::cout << "Constructing Exercises..." << std::endl; - - IO* io = new IO("pfClusterTools.opt"); - Exercises3* ex = new Exercises3(io); - std::cout << "Constructed exercises and options, calibrating...\n"; - TChain c("extraction/Extraction"); - c.Add("../../../../../DipionDelV2_famosPions_0to30GeV_threshApp_200k.root"); - c.Add("../../../../../DipionDelV2_famosPions_0to300GeV_threshApp_200k.root"); - //c.SetBranchStatus("*", 1); - //ex.calibrateCalibratables("../../../../../DipionDelV2_famosPions_0to300GeV_threshApp_200k.root","Exercises300.root"); - //ex.calibrateCalibratables("../../../../../DipionDelV2_famosPions_0to30GeV_threshApp_200k.root","Exercises30.root"); - ex->calibrateCalibratables(c, "ExercisesCombined.root"); - TFile f("ExercisesCombined.root","update"); - gROOT->ProcessLine(".L src/makePlots.cc"); - gROOT->ProcessLine("makePlots(f)"); - f.Write(); - f.Close(); -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/doCalibTestbeam.C b/RecoParticleFlow/PFClusterTools/test/src/doCalibTestbeam.C deleted file mode 100644 index bcd8c1b55a432..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/doCalibTestbeam.C +++ /dev/null @@ -1,30 +0,0 @@ - -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - - std::cout << "Constructing Exercises..." << std::endl; - - IO* io = new IO("pfClusterToolsTB.opt"); - Exercises3* ex = new Exercises3(io); - std::cout << "Constructed exercises and options, calibrating...\n"; - TChain c("extraction/Extraction"); - c.Add("outputtree_2GeV.root"); - c.Add("outputtree_3GeV.root"); - c.Add("outputtree_4GeV.root"); - c.Add("outputtree_5GeV.root"); - c.Add("outputtree_6GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_7GeV.root"); - c.Add("outputtree_8GeV.root"); - c.Add("outputtree_9GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_1000GeV.root"); - - ex->calibrateCalibratables(c, "ExercisesTB.root"); - TFile f("ExercisesTB.root","update"); - gROOT->ProcessLine(".L src/makePlots.cc"); - gROOT->ProcessLine("makePlots(f)"); - f.Write(); - f.Close(); -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/exportCSV.C b/RecoParticleFlow/PFClusterTools/test/src/exportCSV.C deleted file mode 100644 index c4dfa51dacdf0..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/exportCSV.C +++ /dev/null @@ -1,24 +0,0 @@ - -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - TreeUtility tu; - TChain c("extraction/Extraction"); - c.Add("/castor/cern.ch/user/b/ballin/DipionDelegate_50GeV_BarrelOnly_100k_2_1_11.root"); - //c.Add("/castor/cern.ch/user/b/ballin/DipionDelV2_famosPions_0to30GeV_threshApp_200k.root"); - /*c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_1000GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_2GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_3GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_4GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_5GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_6GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_7GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_8GeV.root"); - c.Add("/castor/cern.ch/user/b/ballin/tbv5/outputtree_9GeV.root"); - */ - - tu.dumpCaloDataToCSV(c, "50GeVPions_flat.csv", 50); - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/init.C b/RecoParticleFlow/PFClusterTools/test/src/init.C deleted file mode 100644 index 27ef035da3bd4..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/init.C +++ /dev/null @@ -1,13 +0,0 @@ -{ -/* - * A Root macro to initialise testing of the functionality of the PFClusterTools package - * - */ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - using namespace std; - using namespace pftools; - - //gSystem->Load("src/makePlots.C"); - //makePlots(); -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/makePlots.cc b/RecoParticleFlow/PFClusterTools/test/src/makePlots.cc deleted file mode 100644 index 1aad08b103455..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/makePlots.cc +++ /dev/null @@ -1,268 +0,0 @@ -void makePlots(TFile& file) { - //TFile file("Exercises.root", "update"); - TTree* tv__tree = (TTree *) gROOT->FindObject("CalibratedParticles"); - //tv__tree->AddFriend("extraction/Extraction", "Exercises300.root"); - TDirectory* plots = file.mkdir("plots"); - file.cd("/plots"); - - plots->mkdir("linearity"); - plots->mkdir("targetFunction"); - plots->mkdir("bias"); - plots->mkdir("ratios"); - plots->mkdir("resolutions"); - plots->mkdir("resolutions30"); - - file.cd("/plots/linearity"); - - tv__tree->Draw( - "calibrations_.particleEnergy_:sim_energyEvent_>>uncalibrated", - "calibrations_.provenance_ == 0", "box"); - doLinearityPlots(file, "uncalibrated", "Uncalibrated", kRed); - doRatioPlots(file, "uncalibrated", "Uncalibrated", kRed); - doTargetFunctions(file, "uncalibrated", "Uncalibrated", kRed); - - file.cd("/plots/linearity"); - tv__tree->Draw( - "calibrations_.particleEnergy_:sim_energyEvent_>>calibrated", - "calibrations_.provenance_ > 0", "box"); - doLinearityPlots(file, "calibrated", "Calibrated", kBlue); - doRatioPlots(file, "calibrated", "Calibrated", kBlue); - doTargetFunctions(file, "calibrated", "Calibrated", kBlue); - - file.cd("/plots/linearity"); - tv__tree->Draw( - "calibrations_.particleEnergy_:sim_energyEvent_>>calibratedCorr", - "calibrations_.provenance_ < 0", "box"); - doLinearityPlots(file, "calibratedCorr", "Calibrated and corrected", - kViolet); - doRatioPlots(file, "calibratedCorr", "Calibrated and corrected", kViolet); - doTargetFunctions(file, "calibratedCorr", "Calibrated and corrected", - kViolet); - - file.cd("/plots/ratios"); - tv__tree->Draw( - "calibrations_.ratio_:sim_energyEvent_>>calibratedCorr_fullRatio", - "calibrations_.provenance_ < 0", "col"); - doFullRatioPlots(file, "calibratedCorr", "Corrected", kViolet); - tv__tree->Draw( - "calibrations_.ratio_:sim_energyEvent_>>calibrated_fullRatio", - "calibrations_.provenance_ > 0", "col"); - doFullRatioPlots(file, "calibrated", "Calibrated", kBlue); - - tv__tree->Draw( - "calibrations_.ratio_:sim_energyEvent_>>uncalibrated_fullRatio", - "calibrations_.provenance_ == 0", "col"); - doFullRatioPlots(file, "uncalibrated", "Uncalibrated", kRed); - - file.cd("/plots/bias"); - tv__tree->Draw("calibrations_.bias_:sim_energyEvent_>>calibrated_bias", - "calibrations_.provenance_ > 0", "box"); - doBiasPlots(file, "calibrated_bias", "Calibrated", kBlue); - - tv__tree->Draw("calibrations_.bias_:sim_energyEvent_>>calibratedCorr_bias", - "calibrations_.provenance_ < 0", "box"); - doBiasPlots(file, "calibratedCorr_bias", "Calibrated and corrected", - kViolet); - - tv__tree->Draw("calibrations_.bias_:sim_energyEvent_>>uncalibrated_bias", - "calibrations_.provenance_ == 0", "box"); - doBiasPlots(file, "uncalibrated_bias", "Uncalibrated", kRed); - - file.cd("/plots/resolutions30"); - doResolution(tv__tree,"(20,1.0,6.0,100,0,50)","calibrations_.provenance_ < 0", "Corrected", kViolet); - doResolution(tv__tree,"(20,1.0,6.0,100,0,50)","calibrations_.provenance_ > 0", "Calibrated", kBlue); - doResolution(tv__tree,"(20,1.0,6.0,100,0,50)","calibrations_.provenance_ == 0", "Uncalibrated", kRed); - - /* - file.cd("/plots/resolutions"); - - doResolution(tv__tree,"(20,1.0,18.0,100,0,500)","calibrations_.provenance_ < 0", "Corrected", kViolet); - doResolution(tv__tree,"(20,1.0,18.0,100,0,500)","calibrations_.provenance_ > 0", "Calibrated", kBlue); - doResolution(tv__tree,"(20,1.0,18.0,100,0,500)","calibrations_.provenance_ == 0", "Uncalibrated", kRed); - */ -} - -void doFullRatioPlots(TFile& f, std::string leadingName, std::string title, - Color_t color = kBlack) { - std::string leadingName_1(leadingName); - leadingName_1.append("_fullRatio"); - TH2D* source = (TH2D*) gDirectory->Get(leadingName_1.c_str()); - source->SetTitle(title.c_str()); - std::string leadingName_profile(leadingName_1); - leadingName_profile.append("_pfx"); - source->ProfileX(); - TProfile * profile = - (TProfile*) gDirectory->Get(leadingName_profile.c_str()); - profile->SetTitle(title.c_str()); - profile->SetMarkerStyle(22); - profile->SetMarkerColor(color); - profile->SetXTitle("E_{true}"); - profile->SetYTitle("E_{reco}/E_{true}"); - source->SetXTitle("E_{true}"); - source->SetYTitle("E_{reco}/E_{true}"); - profile->Write(); - source->Write(); - -} - -void doLinearityPlots(TFile& f, std::string leadingName, std::string title, - Color_t color = kBlack) { - - std::string leadingName_1(leadingName); - leadingName_1.append("_1"); - std::string leadingName_2(leadingName); - leadingName_2.append("_2"); - std::string leadingName_profile(leadingName); - leadingName_profile.append("_pfx"); - std::string titleCpy(title); - - TH2D* source = (TH2D*) gDirectory->Get(leadingName.c_str()); - source->FitSlicesY(); - source->ProfileX(); - TProfile * profile = - (TProfile*) gDirectory->Get(leadingName_profile.c_str()); - title.append(" sample mean"); - profile->SetTitle(title.c_str()); - profile->SetMarkerStyle(22); - profile->SetMarkerColor(color); - profile->Write(); - TH1D* source_1 = (TH1D*) gDirectory->Get(leadingName_1.c_str()); - titleCpy.append(" fitted mean"); - source_1->SetTitle(titleCpy.c_str()); - source_1->SetXTitle("E_{true} (GeV)"); - source_1->SetYTitle("calibrations_.particleEnergy_"); - source_1->SetMarkerStyle(22); - source_1->SetMarkerColor(color); - source_1->Write(); - source->Write(); - TH1D* source_2 = (TH1D*) gDirectory->Get(leadingName_2.c_str()); - source_2->SetMarkerStyle(22); - source_2->SetMarkerColor(color); - source_2->Write(); -} - -void doBiasPlots(TFile& f, std::string leadingName, std::string title, - Color_t color = kBlack) { - f.cd("/plots/bias"); - std::string leadingName_1(leadingName); - leadingName_1.append("_1"); - std::string leadingName_profile(leadingName); - leadingName_profile.append("_pfx"); - std::string titleCpy(title); - - TH2D* bias = (TH2D*) gDirectory->Get(leadingName.c_str()); - bias->FitSlicesY(); - bias->ProfileX(); - TProfile * profile = - (TProfile*) gDirectory->Get(leadingName_profile.c_str()); - title.append(" sample bias"); - profile->SetTitle(title.c_str()); - profile->SetXTitle("E_{true} (GeV)"); - profile->SetYTitle("calibrations_.bias_"); - profile->SetMarkerStyle(22); - profile->SetMarkerColor(color); - profile->Write(); - TH1D* bias_1 = (TH1D*) gDirectory->Get(leadingName_1.c_str()); - titleCpy.append(" fitted bias"); - bias_1->SetTitle(titleCpy.c_str()); - bias_1->SetXTitle("E_{true} (GeV)"); - bias_1->SetYTitle("calibrations_.bias_"); - bias_1->SetMarkerStyle(22); - bias_1->SetMarkerColor(color); - bias_1->Write(); - bias->Write(); -} - -void doRatioPlots(TFile& f, std::string leadingName, std::string title, - Color_t color = kBlack) { - std::string leadingName_ratio(leadingName); - leadingName_ratio.append("_ratio"); - std::string leadingName_1(leadingName); - leadingName_1.append("_pfx"); - - TH1D* source = (TH1D*) gDirectory->Get(leadingName_1.c_str()); - - double start = source->GetBinLowEdge(1); - double width = source->GetBinWidth(1); - double end = source->GetBinLowEdge(source->GetNbinsX() + 1); - - TH1F* ratio = new TH1F(leadingName_ratio.c_str(), title.c_str(), source->GetNbinsX(), start, end); - ratio->SetXTitle("E_{true} (GeV)"); - ratio->SetYTitle("E_{reco}/E_{true}"); - for (unsigned k(1); k < source->GetNbinsX() + 1; ++k) { - double ratioVal = source->GetBinContent(k)/(width * k + start); - ratio->Fill(width * k + start, ratioVal); - } - ratio->SetMarkerStyle(22); - ratio->SetMarkerColor(color); - ratio->Write(); -} - -void doTargetFunctions(TFile& f, std::string leadingName, std::string title, - Color_t color = kBlack) { - - //for each in [un]calibrated(Corr)_1, _2, divide bin entry in _2 by _1 bin entry. Multiply by sqrt of bin center. - - std::string leadingName_1(leadingName); - std::string leadingName_2(leadingName); - std::string leadingName_targ(leadingName); - leadingName_1.append("_1"); - leadingName_2.append("_2"); - leadingName_targ.append("_targ"); - - TH1D* source = (TH1D*) gDirectory->Get(leadingName_2.c_str()); - TH1D* means = (TH1D*) gDirectory->Get(leadingName_1.c_str()); - f.cd("/plots/targetFunction"); - double start = source->GetBinLowEdge(1); - double width = source->GetBinWidth(1); - double end = source->GetBinLowEdge(source->GetNbinsX() + 1); - - TH1F* targ = new TH1F(leadingName_targ.c_str(), title.c_str(), source->GetNbinsX(), start, end); - targ->SetXTitle("E_{true} (GeV)"); - targ->SetYTitle("Target function"); - for (unsigned k(1); k < source->GetNbinsX() + 1; ++k) { - if (means->GetBinContent(k) != 0) { - double targVal = source->GetBinContent(k)/ means->GetBinContent(k) - * sqrt(width * k + start); - targ->Fill(width * k + start, targVal); - } - } - targ->SetMarkerStyle(22); - targ->SetMarkerColor(color); - targ->Write(); - -} - -void doResolution(TTree* t, std::string queryBins, std::string cut, - std::string name, Color_t color = kBlack) { - - std::string qryName("calibrations_.particleEnergy_:sqrt(calibrations_.truthEnergy_)>>"); - qryName.append(name); - qryName.append(queryBins); - - std::string name1(name); - std::string name2(name); - name1.append("_1"); - name2.append("_2"); - std::string leadingName_res(name); - leadingName_res.append("_res"); - - - //do tree business here - t->Draw(qryName.c_str(), cut.c_str(),"box"); - TH2* temp = (TH2*) gDirectory->FindObject(name.c_str()); - temp->FitSlicesY(); - TH1* reso = ((TH1*) gDirectory->FindObject(name2.c_str()))->Clone(); - TH1* mean = ((TH1*) gDirectory->FindObject(name1.c_str()))->Clone(); - reso->Divide(mean); - reso->SetTitle(name.c_str()); - reso->SetName(leadingName_res.c_str()); - reso->SetMarkerStyle(22); - reso->SetMarkerColor(color); - TF1* f = new TF1(name.c_str(), "[0]/x + [1]/(x*x)"); - reso->Fit(f); - f->Write(); - reso->Write(); - leadingName_res.append("_graph"); - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/testConversion.C b/RecoParticleFlow/PFClusterTools/test/src/testConversion.C deleted file mode 100644 index b699ca14617b2..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/testConversion.C +++ /dev/null @@ -1,58 +0,0 @@ -{ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - std::cout << "Loaded libraries." << std::endl; - //TFile f("singleParticle.root"); - - using namespace std; - using namespace pftools; - - TFile* testConversion = new TFile("TestConversion.root", "recreate"); - testConversion->mkdir("extraction"); - testConversion->cd("extraction"); - TTree* tree = new TTree("Extraction", ""); - Calibratable* c = new Calibratable(); - tree->Branch("Calibratable", "pftools::Calibratable", &c, 32000, 2); - - std::cout << "Initialised objects etc.\n"; - TRandom2 rand2; - for (unsigned u(0); u < 1000; ++u) { - double eta, phi, energy, ecalFrac, gaussSamp; - - eta = rand2.Uniform(0, 1.5); - phi = rand2.Uniform(0, 3.14); - energy = rand2.Uniform(2, 20); - ecalFrac = rand2.Uniform(0, 1.0); - gaussSamp = rand2.Gaus(1, 0.3); - //gaussSamp = 1.0; - - c->reset(); - c->sim_energyEvent_ = energy; - c->sim_isMC_ = 1; - c->sim_eta_ = eta; - c->sim_phi_ = phi; - - //if(ecalFrac * energy < 2.0) { - // energy -= 2.0; - //} - CalibratableElement cecal(0.9 * energy * gaussSamp * ecalFrac -0.2, eta, phi, 1); - CalibratableElement chcal(0.7 * energy * gaussSamp * (1 - ecalFrac) -0.1, eta, phi, 2); - c->cluster_ecal_.push_back(cecal); - c->cluster_hcal_.push_back(chcal); - c->recompute(); - c->cluster_energyEvent_ = c->cluster_energyEcal_ + c->cluster_energyHcal_; - c->cluster_numEcal_ = 1; - c->cluster_numHcal_ = 1; - - tree->Fill(); - - } - tree->Write(); - testConversion->Write(); - testConversion->Close(); - std::cout << "If all is working with ECAL x0.9, -0.5; HCAL x0.7, -1.2 and 0.01 deposit on OFFSET, you should get:\n"; - std::cout << "Calibrations: [2269.84, 1.11111, 1.42857 ]\n"; - // CalibratableElement cecal(0.9 * energy * ecalFrac -0.5, eta, phi, 1); - // CalibratableElement chcal(0.7 * energy * (1 - ecalFrac) -1.2, eta, phi, 2); - std::cout << "Finished.\n"; - -} diff --git a/RecoParticleFlow/PFClusterTools/test/src/testWrappers.C b/RecoParticleFlow/PFClusterTools/test/src/testWrappers.C deleted file mode 100644 index 1b885de387567..0000000000000 --- a/RecoParticleFlow/PFClusterTools/test/src/testWrappers.C +++ /dev/null @@ -1,32 +0,0 @@ -{ -/* - * A Root macro to initialise testing of the functionality of the PFClusterTools package - * - */ - gSystem->Load("libRecoParticleFlowPFClusterTools.so"); - - TFile f("TestWrappers.root", "recreate"); - - using namespace std; - - using namespace pftools; - - TTree* tree = new TTree("WrapperTest", ""); - - SingleParticleWrapper* mySpw = new SingleParticleWrapper(); - - tree->Branch("SingleParticleWrapper", - "pftools::SingleParticleWrapper", &mySpw, 32000, 2); - - CalibrationResultWrapper crw1; - CalibrationResultWrapper crw2; - crw2.ecalEnergy_ = 4.0; - crw2.provenance_ = 1; - mySpw->calibrations_.push_back(crw1); - mySpw->calibrations_.push_back(crw2); - - tree->Fill(); - tree->Write(); - f.Write(); - -} diff --git a/RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h b/RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h deleted file mode 100644 index e6577e0a94e1a..0000000000000 --- a/RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RecoParticleFlow_PFProducer_GsfElectronEqual -#define RecoParticleFlow_PFProducer_GsfElectronEqual - -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" -#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" - - -class GsfElectronEqual { - public: - GsfElectronEqual(const reco::GsfTrackRef& gsfRef):ref_(gsfRef) {;} - ~GsfElectronEqual(){;} - inline bool operator() (const reco::GsfElectron & gsfelectron) { - return (gsfelectron.gsfTrack()==ref_); - } - private: - reco::GsfTrackRef ref_; -}; - -#endif - - diff --git a/RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h b/RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h index 3cb4f2a2a6259..379606f2ef49c 100644 --- a/RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h +++ b/RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h @@ -9,9 +9,7 @@ class KDTreeLinkerBase { public: - KDTreeLinkerBase(); - - virtual ~KDTreeLinkerBase(); + virtual ~KDTreeLinkerBase() {} void setTargetType(const reco::PFBlockElement::Type& tgt) { _targetType = tgt; @@ -31,15 +29,9 @@ class KDTreeLinkerBase // Get/Set of the maximal size of the cristal (ECAL, HCAL,...) in phi/eta and // X/Y. By default, thus value are set for the ECAL cristal. - void setCristalPhiEtaMaxSize(float size); - void setCristalXYMaxSize(float size); - float getCristalPhiEtaMaxSize() const; - float getCristalXYMaxSize() const; // Get/Set phi offset. See bellow in the description of phiOffset_ to understand // the application. - void setPhiOffset(double phiOffset); - float getPhiOffset() const; // Debug flag. void setDebug(bool isDebug); @@ -69,23 +61,29 @@ class KDTreeLinkerBase // This method calls is the good order buildTree(), searchLinks(), // updatePFBlockEltWithLinks() and clear() - virtual void process(); + inline void process() + { + buildTree(); + searchLinks(); + updatePFBlockEltWithLinks(); + clear(); + } protected: // target and field reco::PFBlockElement::Type _targetType,_fieldType; // Cristal maximal size. By default, thus value are set for the ECAL cristal. - float cristalPhiEtaMaxSize_; - float cristalXYMaxSize_; + float cristalPhiEtaMaxSize_ = 0.04; + float cristalXYMaxSize_ = 3.; // Usually, phi is between -Pi and +Pi. But phi space is circular, that's why an element // with phi = 3.13 and another with phi = -3.14 are close. To solve this problem, during // the kdtree building step, we duplicate some elements close enough to +Pi (resp -Pi) by // substracting (adding) 2Pi. This field define the threshold of this operation. - float phiOffset_; + float phiOffset_ = 0.25; // Debug boolean. Not used until now. - bool debug_; + bool debug_ = false; }; diff --git a/RecoParticleFlow/PFProducer/interface/PhotonEqual.h b/RecoParticleFlow/PFProducer/interface/PhotonEqual.h deleted file mode 100644 index 07ca0b7209482..0000000000000 --- a/RecoParticleFlow/PFProducer/interface/PhotonEqual.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RecoParticleFlow_PFProducer_PhotonEqual -#define RecoParticleFlow_PFProducer_PhotonEqual - -#include "DataFormats/EgammaCandidates/interface/Photon.h" -#include "DataFormats/EgammaReco/interface/SuperCluster.h" -#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" - - -class PhotonEqual { - public: - PhotonEqual(const reco::SuperClusterRef& scRef):ref_(scRef) {;} - ~PhotonEqual(){;} - inline bool operator() (const reco::Photon & photon) { - return (photon.superCluster()==ref_); - } - private: - reco::SuperClusterRef ref_; -}; - -#endif - - diff --git a/RecoParticleFlow/PFProducer/interface/Utils.h b/RecoParticleFlow/PFProducer/interface/Utils.h deleted file mode 100644 index 8508eb5c18f22..0000000000000 --- a/RecoParticleFlow/PFProducer/interface/Utils.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef RecoParticleFlow_PFProducer_Utils_h -#define RecoParticleFlow_PFProducer_Utils_h - -#include -#include -#include - - -/// \brief Utility functions -/// -/// \author Colin Bernet -/// \date January 2006 - - - -class Utils { - - public: - - /// match a string to a regexp - static bool stringMatch(const char* string, const char* pattern); - - /// get all files matching pattern - static std::vector myGlob(const char* pattern); - - /// returns the date - static std::string date(); - - /// returns angle between mpi and pi - static double mpi_pi(double angle); -}; - -#endif - - diff --git a/RecoParticleFlow/PFProducer/plugins/EFilter.cc b/RecoParticleFlow/PFProducer/plugins/EFilter.cc deleted file mode 100644 index 82fb6b1995c4a..0000000000000 --- a/RecoParticleFlow/PFProducer/plugins/EFilter.cc +++ /dev/null @@ -1,91 +0,0 @@ -// system include files -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -// #include "FWCore/Framework/interface/EDFilter.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" - -// #include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "RecoParticleFlow/PFProducer/plugins/EFilter.h" - - -// #include "FastSimulation/Event/interface/FSimEvent.h" -// #include "FastSimulation/Event/interface/FSimTrack.h" -// #include "FastSimulation/Event/interface/FSimVertex.h" - -// #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" -// #include "FastSimulation/Particle/interface/ParticleTable.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" -// #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h" - - -using namespace edm; -using namespace std; - -EFilter::EFilter(const edm::ParameterSet& iConfig) { - //now do what ever initialization is needed - - inputTagParticles_ = consumes >(iConfig.getParameter("particles")); - - minE_ = iConfig.getUntrackedParameter("minE",-1); - maxE_ = iConfig.getUntrackedParameter("maxE",999999); - minEt_ = iConfig.getUntrackedParameter("minEt",-1); - maxEt_ = iConfig.getUntrackedParameter("maxEt",999999); - - LogWarning("PFProducer")<<"EFilter : will filter particles with " - <= minE_ && e<= maxE_ && - et>= minEt_ && et<= maxEt_ ) { - cout<<"ok "< { - public: - explicit EFilter(const edm::ParameterSet&); - ~EFilter() override; - - private: - bool filter(edm::Event&, const edm::EventSetup&) override; - - // ----------member data --------------------------- -/* edm::ParameterSet vertexGenerator_; */ -/* edm::ParameterSet particleFilter_; */ -/* FSimEvent* mySimEvent; */ - // std::string hepMCModuleLabel_; - - edm::EDGetTokenT > inputTagParticles_; - - double minE_; - double maxE_; - double minEt_; - double maxEt_; -}; - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(EFilter); - -#endif diff --git a/RecoParticleFlow/PFProducer/plugins/PFCandidateListMerger.cc b/RecoParticleFlow/PFProducer/plugins/PFCandidateListMerger.cc deleted file mode 100644 index aa165bc0f9731..0000000000000 --- a/RecoParticleFlow/PFProducer/plugins/PFCandidateListMerger.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* \class PFCandidateMerger - * - * Merges two lists of PFCandidates - * - * \author: L. Gray (FNAL) - * - * - */ -#include "FWCore/Framework/interface/MakerMacros.h" -#include "CommonTools/UtilAlgos/interface/Merger.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" - -typedef Merger PFCandidateListMerger; - -DEFINE_FWK_MODULE( PFCandidateListMerger ); diff --git a/RecoParticleFlow/PFProducer/plugins/PFCandidateProductFromFwdPtrProducer.cc b/RecoParticleFlow/PFProducer/plugins/PFCandidateProductFromFwdPtrProducer.cc deleted file mode 100644 index c6f23e2e53d15..0000000000000 --- a/RecoParticleFlow/PFProducer/plugins/PFCandidateProductFromFwdPtrProducer.cc +++ /dev/null @@ -1,15 +0,0 @@ -#include "CommonTools/UtilAlgos/interface/ProductFromFwdPtrProducer.h" -#include "CommonTools/ParticleFlow/interface/PFCandidateWithSrcPtrFactory.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" - -#include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/Framework/interface/EventSetup.h" - - - -typedef edm::ProductFromFwdPtrProducer PFCandidateProductFromFwdPtrProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(PFCandidateProductFromFwdPtrProducer); diff --git a/RecoParticleFlow/PFProducer/plugins/PFLinker.cc b/RecoParticleFlow/PFProducer/plugins/PFLinker.cc index 449e4640aec96..3111bfaa99185 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFLinker.cc +++ b/RecoParticleFlow/PFProducer/plugins/PFLinker.cc @@ -1,9 +1,8 @@ -#include "RecoParticleFlow/PFProducer/plugins/PFLinker.h" - - -#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h" -#include "RecoParticleFlow/PFProducer/interface/PhotonEqual.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "RecoParticleFlow/PFProducer/plugins/PFLinker.h" +#include "DataFormats/EgammaCandidates/interface/Photon.h" +#include "DataFormats/EgammaReco/interface/SuperCluster.h" +#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" PFLinker::PFLinker(const edm::ParameterSet & iConfig) { @@ -109,8 +108,8 @@ void PFLinker::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // if it is an electron. Find the GsfElectron with the same GsfTrack if (iselectron) { const reco::GsfTrackRef & gsfTrackRef(cand.gsfTrackRef()); - GsfElectronEqual myEqual(gsfTrackRef); - std::vector::const_iterator itcheck=find_if(gsfElectrons->begin(),gsfElectrons->end(),myEqual); + auto itcheck = find_if( gsfElectrons->begin(),gsfElectrons->end(), + [&gsfTrackRef](const auto& ele) {return (ele.gsfTrack()==gsfTrackRef);} ); if(itcheck==gsfElectrons->end()) { if (!forceElectronsInHGCAL_) { std::ostringstream err; @@ -137,8 +136,8 @@ void PFLinker::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // if it is a photon, find the one with the same PF super-cluster if (isphoton) { const reco::SuperClusterRef & scRef(cand.superClusterRef()); - PhotonEqual myEqual(scRef); - std::vector::const_iterator itcheck=find_if(photons->begin(),photons->end(),myEqual); + auto itcheck = find_if( photons->begin(),photons->end(), + [&scRef](const auto& photon) {return photon.superCluster() == scRef;} ); if(itcheck==photons->end()) { std::ostringstream err; err << " Problem in PFLinker: no Photon " << std::endl; diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc index cdb52595ebd8a..2bd756ff9d651 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerPSEcal.cc @@ -146,7 +146,7 @@ KDTreeLinkerPSEcal::searchLinks() // Same envelope for cap et barrel rechits. - double maxEcalRadius = getCristalXYMaxSize() / 2.; + double maxEcalRadius = cristalXYMaxSize_ / 2.; // The inflation factor includes the approximate projection from Preshower to ECAL double inflation = 2.4 - (etaPS-1.6); diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc index 351f9cd01365a..46bc08ce9591c 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackEcal.cc @@ -76,13 +76,13 @@ KDTreeLinkerTrackEcal::buildTree() // Here we solve the problem of phi circular set by duplicating some rechits // too close to -Pi (or to Pi) and adding (substracting) to them 2 * Pi. - if (rh1.dim2 > (M_PI - getPhiOffset())) { + if (rh1.dim2 > (M_PI - phiOffset_)) { double phi = rh1.dim2 - 2 * M_PI; KDTreeNodeInfo rh2(*it, posrep.eta(), phi); eltList.push_back(rh2); } - if (rh1.dim2 < (M_PI * -1.0 + getPhiOffset())) { + if (rh1.dim2 < (M_PI * -1.0 + phiOffset_)) { double phi = rh1.dim2 + 2 * M_PI; KDTreeNodeInfo rh3(*it, posrep.eta(), phi); eltList.push_back(rh3); @@ -90,8 +90,8 @@ KDTreeLinkerTrackEcal::buildTree() } // Here we define the upper/lower bounds of the 2D space (eta/phi). - double phimin = -1.0 * M_PI - getPhiOffset(); - double phimax = M_PI + getPhiOffset(); + double phimin = -1.0 * M_PI - phiOffset_; + double phimax = M_PI + phiOffset_; // etamin-etamax, phimin-phimax KDTreeBox region(-3.0, 3.0, phimin, phimax); @@ -133,7 +133,7 @@ KDTreeLinkerTrackEcal::searchLinks() // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates. // Same envelope for cap et barrel rechits. - double range = getCristalPhiEtaMaxSize() * (2.0 + 1.0 / std::min(1., trackPt / 2.)); + double range = cristalPhiEtaMaxSize_ * (2.0 + 1.0 / std::min(1., trackPt / 2.)); // We search for all candidate recHits, ie all recHits contained in the maximal size envelope. std::vector recHits; diff --git a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc index 40063c619c21b..6838e038d4053 100644 --- a/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc +++ b/RecoParticleFlow/PFProducer/plugins/kdtrees/KDTreeLinkerTrackHcal.cc @@ -13,8 +13,8 @@ DEFINE_EDM_PLUGIN(KDTreeLinkerFactory, KDTreeLinkerTrackHcal::KDTreeLinkerTrackHcal() : KDTreeLinkerBase() { - setCristalPhiEtaMaxSize(0.2); - setPhiOffset(0.32); + cristalPhiEtaMaxSize_ = 0.2; + phiOffset_ = 0.32; } KDTreeLinkerTrackHcal::~KDTreeLinkerTrackHcal() @@ -79,13 +79,13 @@ KDTreeLinkerTrackHcal::buildTree() // Here we solve the problem of phi circular set by duplicating some rechits // too close to -Pi (or to Pi) and adding (substracting) to them 2 * Pi. - if (rh1.dim2 > (M_PI - getPhiOffset())) { + if (rh1.dim2 > (M_PI - phiOffset_)) { double phi = rh1.dim2 - 2 * M_PI; KDTreeNodeInfo rh2(*it, posrep.eta(), phi); eltList.push_back(rh2); } - if (rh1.dim2 < (M_PI * -1.0 + getPhiOffset())) { + if (rh1.dim2 < (M_PI * -1.0 + phiOffset_)) { double phi = rh1.dim2 + 2 * M_PI; KDTreeNodeInfo rh3(*it, posrep.eta(), phi); eltList.push_back(rh3); @@ -93,8 +93,8 @@ KDTreeLinkerTrackHcal::buildTree() } // Here we define the upper/lower bounds of the 2D space (eta/phi). - double phimin = -1.0 * M_PI - getPhiOffset(); - double phimax = M_PI + getPhiOffset(); + double phimin = -1.0 * M_PI - phiOffset_; + double phimax = M_PI + phiOffset_; // etamin-etamax, phimin-phimax KDTreeBox region(-3.0, 3.0, phimin, phimax); @@ -136,8 +136,8 @@ KDTreeLinkerTrackHcal::searchLinks() // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates. // Same envelope for cap et barrel rechits. double inflation = 1.; - double rangeeta = (getCristalPhiEtaMaxSize() * (1.5 + 0.5) + 0.2 * fabs(dHeta)) * inflation; - double rangephi = (getCristalPhiEtaMaxSize() * (1.5 + 0.5) + 0.2 * fabs(dHphi)) * inflation; + double rangeeta = (cristalPhiEtaMaxSize_ * (1.5 + 0.5) + 0.2 * fabs(dHeta)) * inflation; + double rangephi = (cristalPhiEtaMaxSize_ * (1.5 + 0.5) + 0.2 * fabs(dHphi)) * inflation; // We search for all candidate recHits, ie all recHits contained in the maximal size envelope. std::vector recHits; diff --git a/RecoParticleFlow/PFProducer/plugins/PFCandidateFwdPtrProducer.cc b/RecoParticleFlow/PFProducer/plugins/plugins.cc similarity index 53% rename from RecoParticleFlow/PFProducer/plugins/PFCandidateFwdPtrProducer.cc rename to RecoParticleFlow/PFProducer/plugins/plugins.cc index d7729fe991fa5..2a95d15f83f36 100644 --- a/RecoParticleFlow/PFProducer/plugins/PFCandidateFwdPtrProducer.cc +++ b/RecoParticleFlow/PFProducer/plugins/plugins.cc @@ -1,16 +1,23 @@ -#include "CommonTools/UtilAlgos/interface/FwdPtrProducer.h" -#include "CommonTools/ParticleFlow/interface/PFCandidateFwdPtrFactory.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "CommonTools/UtilAlgos/interface/Merger.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" + +#include "CommonTools/UtilAlgos/interface/ProductFromFwdPtrProducer.h" +#include "CommonTools/ParticleFlow/interface/PFCandidateWithSrcPtrFactory.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "CommonTools/UtilAlgos/interface/FwdPtrProducer.h" +#include "CommonTools/ParticleFlow/interface/PFCandidateFwdPtrFactory.h" +typedef Merger PFCandidateListMerger; +typedef edm::ProductFromFwdPtrProducer + PFCandidateProductFromFwdPtrProducer; typedef edm::FwdPtrProducer PFCandidateFwdPtrProducer; -#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE( PFCandidateListMerger ); +DEFINE_FWK_MODULE(PFCandidateProductFromFwdPtrProducer); DEFINE_FWK_MODULE(PFCandidateFwdPtrProducer); - - diff --git a/RecoParticleFlow/PFProducer/python/particleFlowSimParticle_cfi.py b/RecoParticleFlow/PFProducer/python/particleFlowSimParticle_cfi.py index b71f73628d1fd..040b05f93c594 100644 --- a/RecoParticleFlow/PFProducer/python/particleFlowSimParticle_cfi.py +++ b/RecoParticleFlow/PFProducer/python/particleFlowSimParticle_cfi.py @@ -1,5 +1,7 @@ import FWCore.ParameterSet.Config as cms +from FastSimulation.Event.ParticleFilter_cfi import ParticleFilterBlock + particleFlowSimParticle = cms.EDProducer("PFSimParticleProducer", # verbosity verbose = cms.untracked.bool(False), @@ -8,16 +10,9 @@ # replace ParticleFilter.pTMin = 0.5 # flags process_RecTracks = cms.untracked.bool(False), - ParticleFilter = cms.PSet( - EProton = cms.double(5000.0), - # Particles with |eta| > etaMax (momentum direction at primary vertex) - # are not simulated - etaMax = cms.double(5.0), - # Charged particles with pT < pTMin (GeV/c) are not simulated - pTMin = cms.double(0.0), - # Particles with energy smaller than EMin (GeV) are not simulated - EMin = cms.double(0.0) - ), + # + ParticleFilter = ParticleFilterBlock.ParticleFilter.clone(chargedPtMin = 0, EMin = 0), + # TTRHBuilder = cms.string('WithTrackAngle'), process_Particles = cms.untracked.bool(True), Propagator = cms.string('PropagatorWithMaterial'), @@ -35,3 +30,4 @@ #retrieving fastSim SimHits fastSimProducer = cms.untracked.InputTag('fastSimProducer','EcalHitsEB') ) + diff --git a/RecoParticleFlow/PFProducer/setup_pflow b/RecoParticleFlow/PFProducer/setup_pflow deleted file mode 100755 index ba9a369e4c913..0000000000000 --- a/RecoParticleFlow/PFProducer/setup_pflow +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/csh -cd ../.. -cvs co Configuration/StandardSequences/data/Reconstruction.cff -cp -r /afs/cern.ch/user/c/cbern/public/CMSSW/CMSSW_1_3_0/Reconstruction.cff Configuration/StandardSequences/data/Reconstruction.cff diff --git a/RecoParticleFlow/PFProducer/src/BlockElementImporterBase.cc b/RecoParticleFlow/PFProducer/src/BlockElementImporterBase.cc deleted file mode 100644 index e9731eee1fb76..0000000000000 --- a/RecoParticleFlow/PFProducer/src/BlockElementImporterBase.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h" - -EDM_REGISTER_PLUGINFACTORY(BlockElementImporterFactory, - "BlockElementImporterFactory"); diff --git a/RecoParticleFlow/PFProducer/src/BlockElementLinkerBase.cc b/RecoParticleFlow/PFProducer/src/BlockElementLinkerBase.cc deleted file mode 100644 index 1abfddc233299..0000000000000 --- a/RecoParticleFlow/PFProducer/src/BlockElementLinkerBase.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "RecoParticleFlow/PFProducer/interface/BlockElementLinkerBase.h" - -EDM_REGISTER_PLUGINFACTORY(BlockElementLinkerFactory, - "BlockElementLinkerFactory"); diff --git a/RecoParticleFlow/PFProducer/src/KDTreeLinkerBase.cc b/RecoParticleFlow/PFProducer/src/KDTreeLinkerBase.cc deleted file mode 100644 index 3d1c7b5ac27ba..0000000000000 --- a/RecoParticleFlow/PFProducer/src/KDTreeLinkerBase.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include "RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h" - -EDM_REGISTER_PLUGINFACTORY(KDTreeLinkerFactory,"KDTreeLinkerFactory"); - -KDTreeLinkerBase::KDTreeLinkerBase() - : cristalPhiEtaMaxSize_ (0.04), - cristalXYMaxSize_ (3.), - phiOffset_ (0.25), - debug_ (false) -{ -} - -KDTreeLinkerBase::~KDTreeLinkerBase() -{ -} - -void -KDTreeLinkerBase::setCristalPhiEtaMaxSize(float size) -{ - cristalPhiEtaMaxSize_ = size; -} - -void -KDTreeLinkerBase::setCristalXYMaxSize(float size) -{ - cristalXYMaxSize_ = size; -} - -void -KDTreeLinkerBase::setPhiOffset(double phiOffset) -{ - phiOffset_ = phiOffset; -} - -void -KDTreeLinkerBase::setDebug(bool debug) -{ - debug_ = debug; -} - -float -KDTreeLinkerBase::getCristalPhiEtaMaxSize() const -{ - return cristalPhiEtaMaxSize_; -} - -float -KDTreeLinkerBase::getCristalXYMaxSize() const -{ - return cristalXYMaxSize_; -} - -float -KDTreeLinkerBase::getPhiOffset() const -{ - return phiOffset_; -} - -void -KDTreeLinkerBase::process() -{ - buildTree(); - searchLinks(); - updatePFBlockEltWithLinks(); - clear(); -} - - - diff --git a/RecoParticleFlow/PFProducer/src/PFBlockAlgo.cc b/RecoParticleFlow/PFProducer/src/PFBlockAlgo.cc index c1883ebf36fd4..71bd4bd14c7ea 100644 --- a/RecoParticleFlow/PFProducer/src/PFBlockAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFBlockAlgo.cc @@ -1,5 +1,4 @@ #include "RecoParticleFlow/PFProducer/interface/PFBlockAlgo.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" #include "RecoParticleFlow/PFClusterTools/interface/LinkByRecHit.h" #include "DataFormats/ParticleFlowReco/interface/PFBlock.h" #include "DataFormats/TrackReco/interface/Track.h" diff --git a/RecoParticleFlow/PFProducer/src/PFElectronAlgo.cc b/RecoParticleFlow/PFProducer/src/PFElectronAlgo.cc index 048efc56e7db5..1e8b8a099d813 100644 --- a/RecoParticleFlow/PFProducer/src/PFElectronAlgo.cc +++ b/RecoParticleFlow/PFProducer/src/PFElectronAlgo.cc @@ -5,7 +5,6 @@ #include "RecoParticleFlow/PFProducer/interface/PFElectronAlgo.h" #include "RecoParticleFlow/PFProducer/interface/PFMuonAlgo.h" #include "RecoParticleFlow/PFTracking/interface/PFTrackAlgoTools.h" -//#include "DataFormats/ParticleFlowReco/interface/PFBlockElementGsfTrack.h" #include "DataFormats/ParticleFlowReco/interface/PFBlockElementCluster.h" #include "DataFormats/ParticleFlowReco/interface/PFBlockElementBrem.h" #include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h" @@ -15,7 +14,6 @@ #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" #include "RecoParticleFlow/PFProducer/interface/PFElectronExtraEqual.h" -#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h" #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h" #include "RecoParticleFlow/PFClusterTools/interface/PFSCEnergyCalibration.h" #include "RecoParticleFlow/PFClusterTools/interface/PFEnergyResolution.h" @@ -2477,8 +2475,8 @@ void PFElectronAlgo::SetCandidates(const reco::PFBlockRef& blockRef, // By-pass the mva is the electron has been pre-selected bool bypassmva=false; if(useEGElectrons_) { - GsfElectronEqual myEqual(RefGSF); - std::vector::const_iterator itcheck=find_if(theGsfElectrons_->begin(),theGsfElectrons_->end(),myEqual); + auto itcheck = find_if( theGsfElectrons_->begin(),theGsfElectrons_->end(), + [&RefGSF](const auto& ele) {return (ele.gsfTrack() == RefGSF);} ); if(itcheck!=theGsfElectrons_->end()) { if(BDToutput_[cgsf] >= -1.) { // bypass the mva only if the reconstruction went fine @@ -2564,8 +2562,8 @@ void PFElectronAlgo::SetActive(const reco::PFBlockRef& blockRef, // lock only the elements that pass the BDT cut bool bypassmva=false; if(useEGElectrons_) { - GsfElectronEqual myEqual(RefGSF); - std::vector::const_iterator itcheck=find_if(theGsfElectrons_->begin(),theGsfElectrons_->end(),myEqual); + auto itcheck = find_if( theGsfElectrons_->begin(),theGsfElectrons_->end(), + [&RefGSF](const auto& ele) {return (ele.gsfTrack() == RefGSF);} ); if(itcheck!=theGsfElectrons_->end()) { if(BDToutput_[cgsf] >= -1.) bypassmva=true; diff --git a/RecoParticleFlow/PFProducer/src/Utils.cc b/RecoParticleFlow/PFProducer/src/Utils.cc deleted file mode 100644 index 56a061c12fb40..0000000000000 --- a/RecoParticleFlow/PFProducer/src/Utils.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include "RecoParticleFlow/PFProducer/interface/Utils.h" - -#include -#include - - -using namespace std; - -bool Utils::stringMatch(const char* str, const char* pattern) { - int status; - regex_t re; - - if( regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0 ) - return false; - - status = regexec(&re, str, (size_t)0, nullptr, 0); - regfree(&re); - - if (status != 0) - return false; - - return true; -} - -vector Utils::myGlob(const char* pattern) { - - glob_t globbuf; - - globbuf.gl_offs = 2; - glob(pattern, GLOB_TILDE|GLOB_BRACE|GLOB_MARK, nullptr, &globbuf); - - vector results; - for(unsigned i=0; ipi) angle -= pi2; - while(angle<-pi) angle += pi2; - return angle; -} diff --git a/RecoParticleFlow/PFProducer/src/pluginFactories.cc b/RecoParticleFlow/PFProducer/src/pluginFactories.cc new file mode 100644 index 0000000000000..e9e0f2353c0ba --- /dev/null +++ b/RecoParticleFlow/PFProducer/src/pluginFactories.cc @@ -0,0 +1,8 @@ +#include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h" +EDM_REGISTER_PLUGINFACTORY(BlockElementImporterFactory, "BlockElementImporterFactory"); + +#include "RecoParticleFlow/PFProducer/interface/BlockElementLinkerBase.h" +EDM_REGISTER_PLUGINFACTORY(BlockElementLinkerFactory, "BlockElementLinkerFactory"); + +#include "RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h" +EDM_REGISTER_PLUGINFACTORY(KDTreeLinkerFactory,"KDTreeLinkerFactory"); diff --git a/RecoParticleFlow/PFProducer/test/EgGEDPhotonAnalyzer.cc b/RecoParticleFlow/PFProducer/test/EgGEDPhotonAnalyzer.cc index c6cd5a077421f..3f118dd54b456 100644 --- a/RecoParticleFlow/PFProducer/test/EgGEDPhotonAnalyzer.cc +++ b/RecoParticleFlow/PFProducer/test/EgGEDPhotonAnalyzer.cc @@ -43,7 +43,7 @@ #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" +#include "DataFormats/Math/interface/normalizedPhi.h" #include #include @@ -281,7 +281,7 @@ EgGEDPhotonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iS float phi = (*it).phi(); float deta = etamc - eta; - float dphi = Utils::mpi_pi(phimc - phi); + float dphi = normalizedPhi(phimc - phi); float dR = sqrt(deta*deta + dphi*dphi); if(dR < 0.1){ @@ -350,7 +350,7 @@ EgGEDPhotonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iS float deta = etamc - etareco; - float dphi = Utils::mpi_pi(phimc - phireco); + float dphi = normalizedPhi(phimc - phireco); float dR = sqrt(deta*deta + dphi*dphi); float SCEnergy = (theRecoPh[j]).energy(); @@ -414,7 +414,7 @@ EgGEDPhotonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iS float deta = etamc - etareco; - float dphi = Utils::mpi_pi(phimc - phireco); + float dphi = normalizedPhi(phimc - phireco); float dR = sqrt(deta*deta + dphi*dphi); float SCEnergy = (theGedPh[j]).energy(); diff --git a/RecoParticleFlow/PFProducer/test/GsfGEDElectronAnalyzer.cc b/RecoParticleFlow/PFProducer/test/GsfGEDElectronAnalyzer.cc index b97d913adfc6c..3ce7396447d78 100644 --- a/RecoParticleFlow/PFProducer/test/GsfGEDElectronAnalyzer.cc +++ b/RecoParticleFlow/PFProducer/test/GsfGEDElectronAnalyzer.cc @@ -44,8 +44,8 @@ #include "DataFormats/METReco/interface/PFMET.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/Math/interface/normalizedPhi.h" #include @@ -366,7 +366,7 @@ GsfGEDElectronAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& float deta = etamc - eta; - float dphi = Utils::mpi_pi(phimc - phi); + float dphi = normalizedPhi(phimc - phi); float dR = sqrt(deta*deta + dphi*dphi); if(dR < 0.05){ @@ -421,7 +421,7 @@ GsfGEDElectronAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& float deta = etamc - etareco; - float dphi = Utils::mpi_pi(phimc - phireco); + float dphi = normalizedPhi(phimc - phireco); float dR = sqrt(deta*deta + dphi*dphi); float SCEnergy = (theGsfEle[j]).superCluster()->energy(); @@ -559,7 +559,7 @@ GsfGEDElectronAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& float deta = etamc - etareco; - float dphi = Utils::mpi_pi(phimc - phireco); + float dphi = normalizedPhi(phimc - phireco); float dR = sqrt(deta*deta + dphi*dphi); float SCEnergy = (theGedEle[j]).superCluster()->energy(); diff --git a/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml b/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml index 6de7d3b7135ad..9c5c79bd0ad97 100644 --- a/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml +++ b/RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml @@ -13,7 +13,6 @@ - diff --git a/RecoParticleFlow/PFSimProducer/plugins/ConvBremSeedProducer.cc b/RecoParticleFlow/PFSimProducer/plugins/ConvBremSeedProducer.cc index 1e0f49907b484..d6afe260166a1 100644 --- a/RecoParticleFlow/PFSimProducer/plugins/ConvBremSeedProducer.cc +++ b/RecoParticleFlow/PFSimProducer/plugins/ConvBremSeedProducer.cc @@ -1,6 +1,8 @@ #include "RecoParticleFlow/PFSimProducer/plugins/ConvBremSeedProducer.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "TMath.h" + ///RECORD NEEDED #include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometryRecord.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" @@ -33,7 +35,7 @@ #include "DataFormats/GeometrySurface/interface/Surface.h" #include "DataFormats/GeometrySurface/interface/TangentPlane.h" #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h" -#include "FastSimulation/ParticlePropagator/src/ParticlePropagator.cc" +#include "FastSimulation/ParticlePropagator/interface/ParticlePropagator.h" #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h" #include "FastSimulation/TrajectoryManager/interface/InsideBoundsMeasurementEstimator.h" #include "FastSimulation/TrajectoryManager/interface/LocalMagneticField.h" @@ -132,9 +134,8 @@ ConvBremSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) pft->gsfTrackRef()->outerPosition().y(), pft->gsfTrackRef()->outerPosition().z(), 0.); - BaseParticlePropagator theOutParticle=BaseParticlePropagator( RawParticle(mom,pos), + BaseParticlePropagator theOutParticle=BaseParticlePropagator( RawParticle(mom,pos, pft->gsfTrackRef()->charge()), 0,0,B_.z()); - theOutParticle.setCharge(pft->gsfTrackRef()->charge()); ///FIND THE CLUSTER ASSOCIATED TO THE GSF TRACK gc.push_back(GoodCluster(theOutParticle,PPP,0.5)); @@ -165,12 +166,11 @@ ConvBremSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) - BaseParticlePropagator p( RawParticle(mom,pos), + BaseParticlePropagator p( RawParticle(mom,pos,0.), 0,0,B_.z()); - p.setCharge(0); gc.push_back(GoodCluster(p,PPP,0.2)); - ParticlePropagator PP(p,fieldMap_); + ParticlePropagator PP(p,fieldMap_, nullptr); ///LOOP OVER TRACKER LAYER list::const_iterator cyliter= geometry_->cylinderBegin(); @@ -186,7 +186,7 @@ ConvBremSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) LocalMagneticField mf(PP.getMagneticField()); AnalyticalPropagator alongProp(&mf, anyDirection); InsideBoundsMeasurementEstimator est; - const DetLayer* tkLayer = detLayer(*cyliter,PP.Z()); + const DetLayer* tkLayer = detLayer(*cyliter,PP.particle().Z()); if (&(*tkLayer)==nullptr) continue; TrajectoryStateOnSurface trajState = makeTrajectoryState( tkLayer, PP, &mf); @@ -310,8 +310,7 @@ ConvBremSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) XYZTLorentzVector mom = XYZTLorentzVector(gv.x(),gv.y(),gv_corr.z(),ene); XYZTLorentzVector pos = XYZTLorentzVector(gp.x(),gp.y(),gp.z(),0.); - BaseParticlePropagator theOutParticle(RawParticle(mom,pos),0,0,B_.z()); - theOutParticle.setCharge(ch); + BaseParticlePropagator theOutParticle(RawParticle(mom,pos,ch),0,0,B_.z()); int bgc=GoodCluster(theOutParticle,PPP,0.3,true); if (gv.perp()<0.5) continue; @@ -540,13 +539,13 @@ ConvBremSeedProducer::makeTrajectoryState( const DetLayer* layer, const MagneticField* field) const { - GlobalPoint pos( pp.X(), pp.Y(), pp.Z()); - GlobalVector mom( pp.Px(), pp.Py(), pp.Pz()); + GlobalPoint pos( pp.particle().X(), pp.particle().Y(), pp.particle().Z()); + GlobalVector mom( pp.particle().Px(), pp.particle().Py(), pp.particle().Pz()); auto plane = layer->surface().tangentPlane(pos); return TrajectoryStateOnSurface - (GlobalTrajectoryParameters( pos, mom, TrackCharge( pp.charge()), field), *plane); + (GlobalTrajectoryParameters( pos, mom, TrackCharge( pp.particle().charge()), field), *plane); } bool ConvBremSeedProducer::isGsfTrack(const reco::Track & tkv, const TrackingRecHit *h ){ bool istaken=false; @@ -618,10 +617,10 @@ int ConvBremSeedProducer::GoodCluster(const BaseParticlePropagator& ubpg, const if(bpg.getSuccess()!=0){ for (unsigned int i =0; iTMath::TwoPi()) tmp_phi-= TMath::TwoPi(); - float tmp_eta=fabs(pfc[i].position().eta()-bpg.vertex().eta()); + float tmp_eta=fabs(pfc[i].position().eta()-bpg.particle().vertex().eta()); float tmp_dr=sqrt(pow(tmp_phi,2)+pow(tmp_eta,2)); bool isBet=(tmp_drinitializePdt(&(*pdt)); - ParticleTable::Sentry ptable(mySimEvent->theTable()); - LogDebug("PFSimParticleProducer")<<"START event: "<theTable()); Handle > simTracks; iEvent.getByLabel("g4SimHits",simTracks); diff --git a/RecoParticleFlow/PFSimProducer/plugins/TauHadronDecayFilter.h b/RecoParticleFlow/PFSimProducer/plugins/TauHadronDecayFilter.h index 30aefd1561017..b958e832e3e53 100644 --- a/RecoParticleFlow/PFSimProducer/plugins/TauHadronDecayFilter.h +++ b/RecoParticleFlow/PFSimProducer/plugins/TauHadronDecayFilter.h @@ -4,8 +4,6 @@ #include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FastSimulation/Particle/interface/ParticleTable.h" - // -*- C++ -*- // // Package: TauHadronDecayFilter @@ -40,7 +38,6 @@ class TauHadronDecayFilter : public edm::EDFilter { // ----------member data --------------------------- edm::ParameterSet particleFilter_; FSimEvent* mySimEvent; - std::unique_ptr pTableSentry_; }; #endif diff --git a/RecoParticleFlow/PFTracking/BuildFile.xml b/RecoParticleFlow/PFTracking/BuildFile.xml index 542deac84b558..0e121052266bc 100644 --- a/RecoParticleFlow/PFTracking/BuildFile.xml +++ b/RecoParticleFlow/PFTracking/BuildFile.xml @@ -19,7 +19,7 @@ - + diff --git a/RecoParticleFlow/PFTracking/plugins/GoodSeedProducer.cc b/RecoParticleFlow/PFTracking/plugins/GoodSeedProducer.cc index 5701aa58c8e5f..0dfd0e840d515 100644 --- a/RecoParticleFlow/PFTracking/plugins/GoodSeedProducer.cc +++ b/RecoParticleFlow/PFTracking/plugins/GoodSeedProducer.cc @@ -23,7 +23,7 @@ #include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "TrackingTools/Records/interface/TrackingComponentsRecord.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "CommonTools/MVAUtils/interface/GBRForestTools.h" @@ -243,9 +243,8 @@ GoodSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) Tk[i].outerPosition().z(), 0.); - BaseParticlePropagator theOutParticle( RawParticle(mom,pos), + BaseParticlePropagator theOutParticle( RawParticle(mom,pos, Tk[i].charge()), 0,0,B_.z()); - theOutParticle.setCharge(Tk[i].charge()); theOutParticle.propagateToEcalEntrance(false); @@ -261,9 +260,9 @@ GoodSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) PFClusterRef clusterRef; math::XYZPoint meanShowerSaved; if(theOutParticle.getSuccess()!=0){ - ElecTrkEcalPos=GlobalPoint(theOutParticle.vertex().x(), - theOutParticle.vertex().y(), - theOutParticle.vertex().z() + ElecTrkEcalPos=GlobalPoint(theOutParticle.particle().vertex().x(), + theOutParticle.particle().vertex().y(), + theOutParticle.particle().vertex().z() ); constexpr float psLim = 2.50746495928f; // std::sinh(1.65f); @@ -281,7 +280,7 @@ GoodSeedProducer::produce(Event& iEvent, const EventSetup& iSetup) = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS, false); - auto mom = theOutParticle.momentum().Vect(); + auto mom = theOutParticle.particle().momentum().Vect(); auto meanShower = ElecTrkEcalPos + GlobalVector(mom.x(),mom.y(),mom.z()).unit()*ecalShowerDepth; diff --git a/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc b/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc index 045aef6c08137..257fc36131717 100644 --- a/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc +++ b/RecoParticleFlow/PFTracking/src/ConvBremPFTrackFinder.cc @@ -3,7 +3,6 @@ #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" -#include "RecoParticleFlow/PFProducer/interface/Utils.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/EgammaReco/interface/ElectronSeed.h" #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" diff --git a/RecoParticleFlow/PFTracking/src/PFGsfHelper.cc b/RecoParticleFlow/PFTracking/src/PFGsfHelper.cc index b782a9c360026..7bc58bd8b4c9d 100644 --- a/RecoParticleFlow/PFTracking/src/PFGsfHelper.cc +++ b/RecoParticleFlow/PFTracking/src/PFGsfHelper.cc @@ -15,7 +15,7 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "TrackingTools/PatternTools/interface/Trajectory.h" -//#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +//#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" // Add by Daniele diff --git a/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc b/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc index f191104562d31..e832861d9cc28 100644 --- a/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc +++ b/RecoParticleFlow/PFTracking/src/PFTrackTransformer.cc @@ -16,7 +16,7 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "TrackingTools/PatternTools/interface/Trajectory.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" // Add by Daniele @@ -65,10 +65,10 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, XYZTLorentzVector(track.vertex().x(), track.vertex().y(), track.vertex().z(), - 0.)), + 0.), + track.charge()), 0.,0.,B_.z()); - theParticle.setCharge(track.charge()); float pfoutenergy=sqrt((pfmass*pfmass)+track.outerMomentum().Mag2()); BaseParticlePropagator theOutParticle = BaseParticlePropagator( @@ -79,9 +79,9 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, XYZTLorentzVector(track.outerPosition().x(), track.outerPosition().y(), track.outerPosition().z(), - 0.)), + 0.), + track.charge()), 0.,0.,B_.z()); - theOutParticle.setCharge(track.charge()); math::XYZTLorentzVector momClosest @@ -99,8 +99,8 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, theParticle.propagate(); if(theParticle.getSuccess()!=0) pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::BeamPipeOrEndVertex, - math::XYZPoint(theParticle.vertex()), - math::XYZTLorentzVector(theParticle.momentum()))); + math::XYZPoint(theParticle.particle().vertex()), + math::XYZTLorentzVector(theParticle.particle().momentum()))); else { PFTrajectoryPoint dummyMaxSh; pftrack.addPoint(dummyMaxSh); @@ -132,8 +132,8 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, theOutParticle.propagateToPreshowerLayer1(false); if(theOutParticle.getSuccess()!=0) pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::PS1, - math::XYZPoint(theOutParticle.vertex()), - math::XYZTLorentzVector(theOutParticle.momentum()))); + math::XYZPoint(theOutParticle.particle().vertex()), + math::XYZTLorentzVector(theOutParticle.particle().momentum()))); else { PFTrajectoryPoint dummyPS1; pftrack.addPoint(dummyPS1); @@ -143,8 +143,8 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, theOutParticle.propagateToPreshowerLayer2(false); if(theOutParticle.getSuccess()!=0){ pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::PS2, - math::XYZPoint(theOutParticle.vertex()), - math::XYZTLorentzVector(theOutParticle.momentum()))); + math::XYZPoint(theOutParticle.particle().vertex()), + math::XYZTLorentzVector(theOutParticle.particle().momentum()))); isBelowPS=true; } else { PFTrajectoryPoint dummyPS2; @@ -155,19 +155,19 @@ PFTrackTransformer::addPoints( reco::PFRecTrack& pftrack, if(theOutParticle.getSuccess()!=0){ pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::ECALEntrance, - math::XYZPoint(theOutParticle.vertex()), - math::XYZTLorentzVector(theOutParticle.momentum()))); + math::XYZPoint(theOutParticle.particle().vertex()), + math::XYZTLorentzVector(theOutParticle.particle().momentum()))); double ecalShowerDepth - = PFCluster::getDepthCorrection(theOutParticle.momentum().E(), + = PFCluster::getDepthCorrection(theOutParticle.particle().momentum().E(), isBelowPS, false); - math::XYZPoint meanShower=math::XYZPoint(theOutParticle.vertex())+ - math::XYZTLorentzVector(theOutParticle.momentum()).Vect().Unit()*ecalShowerDepth; + math::XYZPoint meanShower=math::XYZPoint(theOutParticle.particle().vertex())+ + math::XYZTLorentzVector(theOutParticle.particle().momentum()).Vect().Unit()*ecalShowerDepth; pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::ECALShowerMax, meanShower, - math::XYZTLorentzVector(theOutParticle.momentum())));} + math::XYZTLorentzVector(theOutParticle.particle().momentum())));} else { if (PT>5. && msgwarning) LogWarning("PFTrackTransformer")<<"KF TRACK "<5.&& msgwarning) LogWarning("PFTrackTransformer")<<"KF TRACK "<5.&& msgwarning) LogWarning("PFTrackTransformer")<<"KF TRACK "<3.0) { //Same value is used in PFBlockAlgo::link( case PFBlockLink::TRACKandHO: theOutParticle.setMagneticField(0); - theOutParticle.setCharge(0); + //theOutParticle.setCharge(0); //Since the B field is 0, there should be no need to change charge theOutParticle.propagateToHOLayer(false); if(theOutParticle.getSuccess()!=0) { pftrack.addPoint(PFTrajectoryPoint(-1,PFTrajectoryPoint::HOLayer, - math::XYZPoint(theOutParticle.vertex()), - math::XYZTLorentzVector(theOutParticle.momentum()))); + math::XYZPoint(theOutParticle.particle().vertex()), + math::XYZTLorentzVector(theOutParticle.particle().momentum()))); } else { - if (PT>5. && abs(theOutParticle.Z()) < 700.25 && msgwarning) + if (PT>5. && abs(theOutParticle.particle().Z()) < 700.25 && msgwarning) LogWarning("PFTrackTransformer")<<"KF TRACK "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5. && abs(theOutParticle.Z()) < 700.25 ) + if (PT>5. && abs(theOutParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) && ((DP/SigmaDP)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((DP/SigmaDP)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((DP/SigmaDP)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((DP/SigmaDP)>3) && abs(theBremParticle.Z()) < 700.25 ) + if ((DP>5.) && ((DP/SigmaDP)>3) && abs(theBremParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.Z()) < 700.25 ) + if ((dp_tang>5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.Z()) < 700.25 ) + if ((dp_tang>5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"BREM "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) LogWarning("PFTrackTransformer")<<"GSF TRACK "< 5. && abs(theOutParticle.Z()) < 700.25 ) + if ( pTtot_out > 5. && abs(theOutParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"GSF TRACK "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3)) LogWarning("PFTrackTransformer")<<"BREM "<5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.Z()) < 700.25 ) + if ((dp_tang>5.) && ((dp_tang/sdp_tang)>3) && abs(theBremParticle.particle().Z()) < 700.25 ) LogWarning("PFTrackTransformer")<<"BREM "< - - + diff --git a/RecoTauTag/RecoTau/data/emptyMVAinputFile b/RecoTauTag/RecoTau/data/emptyMVAinputFile new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/RecoTauTag/RecoTau/data/emptyMVAinputFile @@ -0,0 +1 @@ + diff --git a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h index afbaf54f57861..fe8e9f8232711 100644 --- a/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h +++ b/RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h @@ -23,8 +23,7 @@ #include "DataFormats/PatCandidates/interface/Tau.h" #include "DataFormats/PatCandidates/interface/Electron.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" #include "DataFormats/PatCandidates/interface/PackedCandidate.h" #include "TMVA/Tools.h" diff --git a/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h b/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h index 343bf8dcacdeb..373c29ca4994c 100644 --- a/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h +++ b/RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h @@ -38,6 +38,9 @@ #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include +#include + #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" @@ -86,7 +89,8 @@ class TauDiscriminationProducerBase : public edm::stream::EDProducer<> { evt.getByToken(disc_token, handle); }; }; - + + static void fillProducerDescriptions(edm::ParameterSetDescription& desc); protected: //value given to taus that fail prediscriminants diff --git a/RecoTauTag/RecoTau/plugins/BuildFile.xml b/RecoTauTag/RecoTau/plugins/BuildFile.xml index 5362e6be3f4f6..99e093f3e7d49 100644 --- a/RecoTauTag/RecoTau/plugins/BuildFile.xml +++ b/RecoTauTag/RecoTau/plugins/BuildFile.xml @@ -35,7 +35,7 @@ - + diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationAgainstElectron.cc index eeff941614dc6..3c800451bed63 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationAgainstElectron.cc @@ -4,6 +4,9 @@ #include "RecoTauTag/TauTagTools/interface/TauTagTools.h" #include "FWCore/Utilities/interface/isFinite.h" +#include +#include + /* class CaloRecoTauDiscriminationAgainstElectron * created : Feb 17 2008, * revised : , @@ -27,6 +30,7 @@ class CaloRecoTauDiscriminationAgainstElectron final : public CaloTauDiscrimin ~CaloRecoTauDiscriminationAgainstElectron() override{} double discriminate(const CaloTauRef& theCaloTauRef) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::ESHandle theMagneticField; edm::InputTag CaloTauProducer_; @@ -125,4 +129,28 @@ void CaloRecoTauDiscriminationAgainstElectron::produce(edm::Event& iEvent,const */ } + +void +CaloRecoTauDiscriminationAgainstElectron::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationAgainstElectron + edm::ParameterSetDescription desc; + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + desc.add("leadTrack_HCAL3x3hitsEtSumOverPt_minvalue", 0.1); + desc.add("maxleadTrackHCAL3x3hottesthitDEta", 0.1); + desc.add("ApplyCut_maxleadTrackHCAL3x3hottesthitDEta", false); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("ApplyCut_leadTrackavoidsECALcrack", true); + descriptions.add("caloRecoTauDiscriminationAgainstElectron", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstElectron); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByCharge.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByCharge.cc index 6dd797daab1c9..e27f00e2487c2 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByCharge.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByCharge.cc @@ -1,5 +1,8 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include + /* class CaloRecoTauDiscriminationByCharge * * Discriminates taus by a |charge| == 1 requirement, @@ -20,6 +23,7 @@ class CaloRecoTauDiscriminationByCharge final : public CaloTauDiscriminationProd } ~CaloRecoTauDiscriminationByCharge() override{} double discriminate(const reco::CaloTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: uint32_t chargeReq_; bool oneOrThreeProng_; @@ -35,4 +39,19 @@ double CaloRecoTauDiscriminationByCharge::discriminate( } } + +void +CaloRecoTauDiscriminationByCharge::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByCharge + edm::ParameterSetDescription desc; + desc.add("AbsChargeReq", 1); + desc.add("ApplyOneOrThreeProngCut", false); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducerHighEfficiency")); + descriptions.add("caloRecoTauDiscriminationByCharge", desc); +} DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByCharge); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByDeltaE.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByDeltaE.cc index 95a1356df7f97..35658966c91d6 100755 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByDeltaE.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByDeltaE.cc @@ -2,6 +2,9 @@ #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class CaloRecoTauDiscriminationByDeltaE * created : September 23 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -29,6 +32,7 @@ class CaloRecoTauDiscriminationByDeltaE final : public CaloTauDiscriminationProd void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double DeltaE(const CaloTauRef&) const ; @@ -63,5 +67,27 @@ double CaloRecoTauDiscriminationByDeltaE::DeltaE(const CaloTauRef& tau) const { return tracksE/tau->leadTrackHCAL3x3hitsEtSum() - 1.0; } +void +CaloRecoTauDiscriminationByDeltaE::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByDeltaE + edm::ParameterSetDescription desc; + desc.add("deltaEmin", -0.15); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("deltaEmax", 1.0); + desc.add("BooleanOutput", true); + desc.add("TauProducer", edm::InputTag("caloRecoTauProducer")); + descriptions.add("caloRecoTauDiscriminationByDeltaE", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByDeltaE); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByFlightPathSignificance.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByFlightPathSignificance.cc index fa97daee48cf0..1a97c0945361e 100755 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByFlightPathSignificance.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByFlightPathSignificance.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class CaloRecoTauDiscriminationByFlightPathSignificance * created : September 23 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -37,6 +40,7 @@ class CaloRecoTauDiscriminationByFlightPathSignificance final : public CaloTauDi void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double threeProngFlightPathSig(const CaloTauRef&) const ; double vertexSignificance(reco::Vertex const&,reco::Vertex const &,GlobalVector const &) const ; @@ -104,5 +108,75 @@ CaloRecoTauDiscriminationByFlightPathSignificance::vertexSignificance( } } + +void +CaloRecoTauDiscriminationByFlightPathSignificance::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByFlightPathSignificance + edm::ParameterSetDescription desc; + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + desc.add("flightPathSig", 1.5); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("BooleanOutput", true); + + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + + desc.add("UsePVerror", true); + descriptions.add("caloRecoTauDiscriminationByFlightPathSignificance", desc); +} DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByFlightPathSignificance); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByInvMass.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByInvMass.cc index f58baf44d6e06..c1b9c73688468 100755 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByInvMass.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByInvMass.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class CaloRecoTauDiscriminationByInvMass * created : September 23 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -30,6 +33,7 @@ class CaloRecoTauDiscriminationByInvMass final : public CaloTauDiscriminationPro double discriminate(const reco::CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double threeProngInvMass(const CaloTauRef&) const ; double chargedPionMass; @@ -61,4 +65,27 @@ double CaloRecoTauDiscriminationByInvMass::threeProngInvMass( } } + +void +CaloRecoTauDiscriminationByInvMass::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByInvMass + edm::ParameterSetDescription desc; + desc.add("invMassMin", 0.0); + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("BooleanOutput", true); + desc.add("invMassMax", 1.4); + descriptions.add("caloRecoTauDiscriminationByInvMass", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByInvMass); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByIsolation.cc index c60a22a145a69..bc8b4a57a3bd0 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByIsolation.cc @@ -6,6 +6,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include + namespace { using namespace reco; @@ -15,12 +18,14 @@ class CaloRecoTauDiscriminationByIsolation final : public CaloTauDiscriminationP explicit CaloRecoTauDiscriminationByIsolation(const edm::ParameterSet& iConfig):CaloTauDiscriminationProducerBase(iConfig){ applyDiscriminationByTrackerIsolation_ = iConfig.getParameter("ApplyDiscriminationByTrackerIsolation"); TrackerIsolAnnulus_maximumOccupancy_ = iConfig.getParameter("TrackerIsolAnnulus_maximumOccupancy"); - + applyDiscriminationByECALIsolation_ = iConfig.getParameter("ApplyDiscriminationByECALIsolation"); EcalIsolAnnulus_maximumSumEtCut_ = iConfig.getParameter("ECALisolAnnulus_maximumSumEtCut"); } ~CaloRecoTauDiscriminationByIsolation() override{} double discriminate(const CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: bool applyDiscriminationByTrackerIsolation_; unsigned TrackerIsolAnnulus_maximumOccupancy_; @@ -44,4 +49,19 @@ double CaloRecoTauDiscriminationByIsolation::discriminate(const CaloTauRef& calo } +void +CaloRecoTauDiscriminationByIsolation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByIsolation + edm::ParameterSetDescription desc; + desc.add("ApplyDiscriminationByTrackerIsolation"); + desc.add("TrackerIsolAnnulus_maximumOccupancy"); // unsigned means unsigned int, in my test it resulted in uint32 + desc.add("ApplyDiscriminationByECALIsolation"); + desc.add("ECALisolAnnulus_maximumSumEtCut"); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("caloRecoTauDiscriminationByIsolation", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByIsolation); + diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByLeadingTrackPtCut.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByLeadingTrackPtCut.cc index a5b1658c551d4..1be66a337c8c6 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByLeadingTrackPtCut.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByLeadingTrackPtCut.cc @@ -7,6 +7,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include + #include "DataFormats/TrackReco/interface/Track.h" using namespace reco; @@ -19,6 +22,8 @@ class CaloRecoTauDiscriminationByLeadingTrackPtCut final : public CaloTauDiscrim ~CaloRecoTauDiscriminationByLeadingTrackPtCut() override{} double discriminate(const CaloTauRef& theCaloTauRef) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: double minPtLeadTrack_; }; @@ -35,6 +40,26 @@ double CaloRecoTauDiscriminationByLeadingTrackPtCut::discriminate(const CaloTauR return ( (leadTrackPt_ > minPtLeadTrack_) ? 1. : 0. ); } +void +CaloRecoTauDiscriminationByLeadingTrackPtCut::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByLeadingTrackPtCut + edm::ParameterSetDescription desc; + desc.add("MinPtLeadingTrack", 5.0); + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + { + edm::ParameterSetDescription requireLeadTrackCalo; + requireLeadTrackCalo.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription leadTrack; + leadTrack.add("cut"); + leadTrack.add("Producer"); + requireLeadTrackCalo.add("leadTrack", leadTrack); + } + desc.add("Prediscriminants", requireLeadTrackCalo); + } + descriptions.add("caloRecoTauDiscriminationByLeadingTrackPtCut", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByLeadingTrackPtCut); /* diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByNProngs.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByNProngs.cc index 51897cfe4daaf..9a84414cdcfed 100755 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByNProngs.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByNProngs.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class CaloRecoTauDiscriminationByNProngs * created : September 23 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -23,6 +26,7 @@ class CaloRecoTauDiscriminationByNProngs final ~CaloRecoTauDiscriminationByNProngs() override{} double discriminate(const reco::CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: uint32_t nprongs; bool booleanOutput; @@ -40,4 +44,25 @@ double CaloRecoTauDiscriminationByNProngs::discriminate(const CaloTauRef& tau) c } } + +void +CaloRecoTauDiscriminationByNProngs::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByNProngs + edm::ParameterSetDescription desc; + desc.add("nProngs", 0); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + desc.add("BooleanOutput", true); + descriptions.add("caloRecoTauDiscriminationByNProngs", desc); +} DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByNProngs); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByTauPolarization.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByTauPolarization.cc index f8da61d274b74..09e87c1d49104 100755 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByTauPolarization.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauDiscriminationByTauPolarization.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "DataFormats/TrackReco/interface/Track.h" +#include +#include + /* class CaloRecoTauDiscriminationByTauPolarization * created : September 22 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -23,6 +26,7 @@ class CaloRecoTauDiscriminationByTauPolarization : public CaloTauDiscriminationP ~CaloRecoTauDiscriminationByTauPolarization() override{} double discriminate(const CaloTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool booleanOutput; double rTauMin; @@ -37,4 +41,27 @@ CaloRecoTauDiscriminationByTauPolarization::discriminate(const CaloTauRef& tau) return rTau; } } + +void +CaloRecoTauDiscriminationByTauPolarization::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationByTauPolarization + edm::ParameterSetDescription desc; + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("rtau", 0.8); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("BooleanOutput", true); + descriptions.add("caloRecoTauDiscriminationByTauPolarization", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByTauPolarization); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauProducer.cc index 5a69e42266220..1b17f217ce9fa 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauProducer.cc @@ -25,6 +25,9 @@ #include "CLHEP/Random/RandGauss.h" +#include +#include + #include using namespace reco; @@ -36,6 +39,7 @@ class CaloRecoTauProducer : public EDProducer { explicit CaloRecoTauProducer(const edm::ParameterSet& iConfig); ~CaloRecoTauProducer() override; void produce(edm::Event&,const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::InputTag CaloRecoTauTagInfoProducer_; edm::InputTag PVProducer_; @@ -108,4 +112,49 @@ void CaloRecoTauProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSet iEvent.put(std::move(resultCaloTau)); iEvent.put(std::move(selectedDetIds)); } + +void +CaloRecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauProducer + edm::ParameterSetDescription desc; + desc.add("LeadTrack_minPt", 0.5); + desc.add("MatchingConeSize_min", 0.0); + desc.add("ECALSignalConeSizeFormula", "0.15"); + desc.add("TrackerIsolConeMetric", "DR"); + desc.add("TrackerSignalConeMetric", "DR"); + desc.add("EBRecHitsSource", edm::InputTag("ecalRecHit","EcalRecHitsEB")); + desc.add("IsolationTrack_minPt", 1.0); + desc.add("ECALSignalConeSize_min", 0.0); + desc.add("ECALRecHit_minEt", 0.5); + desc.add("MatchingConeMetric", "DR"); + desc.add("TrackerSignalConeSizeFormula", "0.07"); + desc.add("MatchingConeSizeFormula", "0.10"); + desc.add("TrackerIsolConeSize_min", 0.0); + desc.add("TrackerIsolConeSize_max", 0.6); + desc.add("TrackerSignalConeSize_max", 0.6); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("ESRecHitsSource", edm::InputTag("ecalPreshowerRecHit","EcalRecHitsES")); + desc.add("TrackerSignalConeSize_min", 0.0); + desc.add("ECALIsolConeSize_max", 0.6); + desc.add("AreaMetric_recoElements_maxabsEta", 2.5); + desc.add("ECALIsolConeMetric", "DR"); + desc.add("ECALIsolConeSizeFormula", "0.50"); + desc.add("JetPtMin", 0.0); + desc.add("EERecHitsSource", edm::InputTag("ecalRecHit","EcalRecHitsEE")); + desc.add("IsolationTrack_minHits", 0); + desc.add("ECALSignalConeMetric", "DR"); + desc.add("TrackLeadTrack_maxDZ", 1.0); + desc.add("Track_minPt", 0.5); + desc.add("TrackerIsolConeSizeFormula", "0.50"); + desc.add("ECALSignalConeSize_max", 0.6); + desc.add("ECALIsolConeSize_min", 0.0); + desc.add("UseTrackLeadTrackDZconstraint", true); + desc.add("smearedPVsigmaY", 0.0015); + desc.add("smearedPVsigmaX", 0.0015); + desc.add("smearedPVsigmaZ", 0.005); + desc.add("CaloRecoTauTagInfoProducer", edm::InputTag("caloRecoTauTagInfoProducer")); + desc.add("MatchingConeSize_max", 0.6); + descriptions.add("caloRecoTauProducer", desc); +} + DEFINE_FWK_MODULE(CaloRecoTauProducer); diff --git a/RecoTauTag/RecoTau/plugins/CaloRecoTauTagInfoProducer.cc b/RecoTauTag/RecoTau/plugins/CaloRecoTauTagInfoProducer.cc index 699ce787ec1b8..636fc31f7187b 100644 --- a/RecoTauTag/RecoTau/plugins/CaloRecoTauTagInfoProducer.cc +++ b/RecoTauTag/RecoTau/plugins/CaloRecoTauTagInfoProducer.cc @@ -22,6 +22,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include + #include "DataFormats/DetId/interface/DetIdCollection.h" #include "CLHEP/Random/RandGauss.h" @@ -39,6 +42,7 @@ class CaloRecoTauTagInfoProducer : public EDProducer { explicit CaloRecoTauTagInfoProducer(const edm::ParameterSet&); ~CaloRecoTauTagInfoProducer() override; void produce(edm::Event&,const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: CaloRecoTauTagInfoAlgorithm* CaloRecoTauTagInfoAlgo_; edm::InputTag CaloJetTracksAssociatorProducer_; @@ -94,4 +98,30 @@ void CaloRecoTauTagInfoProducer::produce(edm::Event& iEvent,const edm::EventSetu // iEvent.put(std::move(selectedDetIds)); } + +void +CaloRecoTauTagInfoProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauTagInfoProducer + edm::ParameterSetDescription desc; + desc.add("tkminTrackerHitsn", 3); + desc.add("ECALBasicClustersAroundCaloJet_DRConeSize", 0.5); + desc.add("tkminPixelHitsn", 0); + desc.add("ECALBasicClusterpropagTrack_matchingDRConeSize", 0.015); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("tkminPt", 0.5); + desc.add("smearedPVsigmaX", 0.0015); + desc.add("UsePVconstraint", true); + desc.add("tkmaxChi2", 100.0); + desc.add("EndcapBasicClustersSource", edm::InputTag("multi5x5SuperClusters","multi5x5EndcapBasicClusters")); + desc.add("smearedPVsigmaY", 0.0015); + desc.add("BarrelBasicClustersSource", edm::InputTag("hybridSuperClusters","hybridBarrelBasicClusters")); + desc.add("ECALBasicClusterminE", 1.0); + desc.add("smearedPVsigmaZ", 0.005); + desc.add("tkPVmaxDZ", 1.0); + desc.add("UseTrackQuality", true); + desc.add("tkQuality", "highPurity"); + desc.add("tkmaxipt", 0.1); + desc.add("CaloJetTracksAssociatorProducer", edm::InputTag("ic5JetTracksAssociatorAtVertex")); + descriptions.add("caloRecoTauTagInfoProducer", desc); +} DEFINE_FWK_MODULE(CaloRecoTauTagInfoProducer ); diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminantCutMultiplexer.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminantCutMultiplexer.cc index d8deedb9e94b4..b123b58c3fcae 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminantCutMultiplexer.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminantCutMultiplexer.cc @@ -23,6 +23,9 @@ #include "DataFormats/PatCandidates/interface/Tau.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include +#include + #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTGraphPayload.h" #include "CondFormats/DataRecord/interface/PhysicsTGraphPayloadRcd.h" #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTFormulaPayload.h" @@ -41,7 +44,8 @@ class PATTauDiscriminantCutMultiplexer : public PATTauDiscriminationProducerBase ~PATTauDiscriminantCutMultiplexer() override; double discriminate(const pat::TauRef&) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup) override; - + + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: std::string moduleLabel_; @@ -147,19 +151,13 @@ PATTauDiscriminantCutMultiplexer::PATTauDiscriminantCutMultiplexer(const edm::Pa key_ = cfg.getParameter("key"); key_token = consumes(key_); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; - - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + verbosity_ = cfg.getParameter("verbosity"); + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; } if(verbosity_) std::cout << moduleLabel_ << " loadMVA = " << loadMVAfromDB_ << std::endl; - if ( cfg.exists("mvaOutput_normalization") ) { - mvaOutputNormalizationName_ = cfg.getParameter("mvaOutput_normalization"); - } + mvaOutputNormalizationName_ = cfg.getParameter("mvaOutput_normalization"); // default value is "" which should just overwrite existing value with same empty string // Setup our cut map typedef std::vector VPSet; @@ -182,7 +180,7 @@ PATTauDiscriminantCutMultiplexer::PATTauDiscriminantCutMultiplexer(const edm::Pa } cuts_[category] = std::move(cut); } - + verbosity_ = cfg.getParameter("verbosity"); if(verbosity_) std::cout << "constructed " << moduleLabel_ << std::endl; } @@ -281,4 +279,34 @@ PATTauDiscriminantCutMultiplexer::discriminate(const pat::TauRef& tau) const return passesCuts; } +void +PATTauDiscriminantCutMultiplexer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // patTauDiscriminantCutMultiplexer + edm::ParameterSetDescription desc; + desc.add("toMultiplex", edm::InputTag("fixme")); + desc.add("verbosity", 0); + { + edm::ParameterSetDescription desc_mapping; + desc_mapping.add("category"); + desc_mapping.setAllowAnything(); //option cut can be double or (string plus additional option variable) + + std::vector vpsd_mapping; + edm::ParameterSet psd1; + psd1.addParameter("category", 0); + psd1.addParameter("cut", 0.5); + vpsd_mapping.push_back(psd1); + edm::ParameterSet psd2; + psd2.addParameter("category", 1); + psd2.addParameter("cut", 0.2); + vpsd_mapping.push_back(psd2); + desc.addVPSet("mapping", desc_mapping, vpsd_mapping); + } + desc.add("inputFileName", edm::FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile")); + desc.add("loadMVAfromDB", true); + fillProducerDescriptions(desc); // inherited from the base + desc.add("mvaOutput_normalization", ""); + desc.add("key", edm::InputTag("fixme")); + descriptions.add("patTauDiscriminantCutMultiplexer", desc); +} + DEFINE_FWK_MODULE(PATTauDiscriminantCutMultiplexer); diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc index 89cbb09ffb2be..3c51299f3ce2a 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationAgainstElectronMVA6.cc @@ -7,6 +7,9 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h" @@ -34,8 +37,7 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu srcElectrons = cfg.getParameter("srcElectrons"); electronToken = consumes(srcElectrons); vetoEcalCracks_ = cfg.getParameter("vetoEcalCracks"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); // add category index produces("category"); @@ -49,6 +51,7 @@ class PATTauDiscriminationAgainstElectronMVA6 : public PATTauDiscriminationProdu ~PATTauDiscriminationAgainstElectronMVA6() override{} + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool isInEcalCrack(double) const; @@ -198,4 +201,46 @@ PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack(double eta) const return (absEta > 1.460 && absEta < 1.558); } +void +PATTauDiscriminationAgainstElectronMVA6::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // patTauDiscriminationAgainstElectronMVA6 + edm::ParameterSetDescription desc; + desc.add("minMVANoEleMatchWOgWOgsfBL", 0.0); + desc.add("minMVANoEleMatchWgWOgsfBL", 0.0); + desc.add("vetoEcalCracks", true); + desc.add("usePhiAtEcalEntranceExtrapolation", false); + desc.add("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC"); + desc.add("minMVAWgWgsfBL", 0.0); + desc.add("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC"); + desc.add("minMVAWOgWgsfEC", 0.0); + desc.add("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL"); + desc.add("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL"); + desc.add("returnMVA", true); + desc.add("loadMVAfromDB", true); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL"); + desc.add("srcElectrons", edm::InputTag("slimmedElectrons")); + desc.add("minMVANoEleMatchWOgWOgsfEC", 0.0); + desc.add("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL"); + desc.add("PATTauProducer", edm::InputTag("slimmedTaus")); + desc.add("minMVAWOgWgsfBL", 0.0); + desc.add("minMVAWgWgsfEC", 0.0); + desc.add("verbosity", 0); + desc.add("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC"); + desc.add("method", "BDTG"); + desc.add("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC"); + desc.add("minMVANoEleMatchWgWOgsfEC", 0.0); + descriptions.add("patTauDiscriminationAgainstElectronMVA6", desc); +} + DEFINE_FWK_MODULE(PATTauDiscriminationAgainstElectronMVA6); diff --git a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationByMVAIsolationRun2.cc b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationByMVAIsolationRun2.cc index a1721622ba2b1..61db9502fd95e 100644 --- a/RecoTauTag/RecoTau/plugins/PATTauDiscriminationByMVAIsolationRun2.cc +++ b/RecoTauTag/RecoTau/plugins/PATTauDiscriminationByMVAIsolationRun2.cc @@ -26,6 +26,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/PatCandidates/interface/Tau.h" #include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h" @@ -82,12 +85,10 @@ class PATTauDiscriminationByMVAIsolationRun2 : public PATTauDiscriminationProduc category_output_() { mvaName_ = cfg.getParameter("mvaName"); - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; - } + } std::string mvaOpt_string = cfg.getParameter("mvaOpt"); if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT; else if ( mvaOpt_string == "oldDMwLT" ) mvaOpt_ = kOldDMwLT; @@ -115,18 +116,17 @@ class PATTauDiscriminationByMVAIsolationRun2 : public PATTauDiscriminationProduc photonPtSumOutsideSignalCone_ = cfg.getParameter("srcPhotonPtSumOutsideSignalCone"); footprintCorrection_ = cfg.getParameter("srcFootprintCorrection"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); produces("category"); } - + void beginEvent(const edm::Event&, const edm::EventSetup&) override; - + double discriminate(const TauRef&) const override; - + void endEvent(edm::Event&) override; - + ~PATTauDiscriminationByMVAIsolationRun2() override { if(!loadMVAfromDB_) delete mvaReader_; @@ -136,7 +136,9 @@ class PATTauDiscriminationByMVAIsolationRun2 : public PATTauDiscriminationProduc delete (*it); } } - + + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; @@ -207,6 +209,28 @@ void PATTauDiscriminationByMVAIsolationRun2::endEvent(edm::Event& evt) evt.put(std::move(category_output_), "category"); } +void +PATTauDiscriminationByMVAIsolationRun2::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // patTauDiscriminationByMVAIsolationRun2 + edm::ParameterSetDescription desc; + + desc.add("mvaName"); + desc.add("loadMVAfromDB"); + desc.addOptional("inputFileName"); + desc.add("mvaOpt"); + + desc.add("srcChargedIsoPtSum"); + desc.add("srcNeutralIsoPtSum"); + desc.add("srcPUcorrPtSum"); + desc.add("srcPhotonPtSumOutsideSignalCone"); + desc.add("srcFootprintCorrection"); + desc.add("verbosity", 0); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("patTauDiscriminationByMVAIsolationRun2", desc); +} + DEFINE_FWK_MODULE(PATTauDiscriminationByMVAIsolationRun2); }} //namespace diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc index 03016fd1c70c8..602ebd5fe147d 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromPFCandidatePlugin.cc @@ -102,8 +102,7 @@ class PFRecoTauChargedHadronFromPFCandidatePlugin : public PFRecoTauChargedHadro minMergeGammaEt_ = pset.getParameter("minMergeGammaEt"); minMergeChargedHadronPt_ = pset.getParameter("minMergeChargedHadronPt"); - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } PFRecoTauChargedHadronFromPFCandidatePlugin::~PFRecoTauChargedHadronFromPFCandidatePlugin() diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc index e4aead1c12740..53818afe6d602 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronFromTrackPlugin.cc @@ -28,8 +28,8 @@ #include "DataFormats/Common/interface/Ptr.h" #include "DataFormats/Math/interface/deltaR.h" -#include "FastSimulation/BaseParticlePropagator/interface/BaseParticlePropagator.h" -#include "FastSimulation/Particle/interface/RawParticle.h" +#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h" +#include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" @@ -95,8 +95,7 @@ class PFRecoTauChargedHadronFromTrackPlugin : public PFRecoTauChargedHadronBuild numWarnings_ = 0; maxWarnings_ = 3; - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } PFRecoTauChargedHadronFromTrackPlugin::~PFRecoTauChargedHadronFromTrackPlugin() @@ -196,11 +195,12 @@ PFRecoTauChargedHadronFromTrackPlugin::return_type PFRecoTauChargedHadronFromTra // (outerMomentum and outerPosition require access to reco::TrackExtra objects, which are available in RECO only) // XYZTLorentzVector chargedPionPos(track->referencePoint().x(), track->referencePoint().y(), track->referencePoint().z(), 0.); - BaseParticlePropagator trackPropagator(RawParticle(chargedPionP4, chargedPionPos), 0., 0., magneticFieldStrength_.z()); - trackPropagator.setCharge(track->charge()); + RawParticle p(chargedPionP4, chargedPionPos); + p.setCharge(track->charge()); + BaseParticlePropagator trackPropagator(p, 0., 0., magneticFieldStrength_.z()); trackPropagator.propagateToEcalEntrance(false); if ( trackPropagator.getSuccess() != 0 ) { - chargedHadron->positionAtECALEntrance_ = trackPropagator.vertex(); + chargedHadron->positionAtECALEntrance_ = trackPropagator.particle().vertex(); } else { if ( chargedPionP4.pt() > 2. and std::abs(chargedPionP4.eta()) < 3. ) { edm::LogWarning("PFRecoTauChargedHadronFromTrackPlugin::operator()") diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc index 2210e25132edf..521a4c63eb0cf 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauChargedHadronProducer.cc @@ -19,6 +19,9 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/PFRecoTauChargedHadronPlugins.h" #include "RecoTauTag/RecoTau/interface/RecoTauCleaningTools.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" @@ -60,6 +63,8 @@ class PFRecoTauChargedHadronProducer : public edm::stream::EDProducer<> template void print(const T& chargedHadrons); + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: typedef boost::ptr_vector builderList; typedef boost::ptr_vector rankerList; @@ -94,10 +99,9 @@ PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(const edm::Parame { srcJets_ = cfg.getParameter("jetSrc"); Jets_token = consumes(srcJets_); - minJetPt_ = ( cfg.exists("minJetPt") ) ? cfg.getParameter("minJetPt") : -1.0; - maxJetAbsEta_ = ( cfg.exists("maxJetAbsEta") ) ? cfg.getParameter("maxJetAbsEta") : 99.0; - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + minJetPt_ = cfg.getParameter("minJetPt"); + maxJetAbsEta_ = cfg.getParameter("maxJetAbsEta"); + verbosity_ = cfg.getParameter("verbosity"); // get set of ChargedHadron builder plugins edm::VParameterSet psets_builders = cfg.getParameter("builders"); @@ -123,11 +127,9 @@ PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(const edm::Parame predicate_ = std::auto_ptr(new ChargedHadronPredicate(rankers_)); // check if we want to apply a final output selection - if ( cfg.exists("outputSelection") ) { - std::string selection = cfg.getParameter("outputSelection"); - if ( !selection.empty() ) { - outputSelector_.reset(new StringCutObjectSelector(selection)); - } + std::string selection = cfg.getParameter("outputSelection"); + if ( !selection.empty() ) { + outputSelector_.reset(new StringCutObjectSelector(selection)); } produces(); @@ -314,6 +316,108 @@ void PFRecoTauChargedHadronProducer::print(const T& chargedHadrons) } } +void +PFRecoTauChargedHadronProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // ak4PFJetsRecoTauChargedHadrons + edm::ParameterSetDescription desc; + { + edm::ParameterSetDescription vpsd_ranking; + vpsd_ranking.add("selectionPassFunction", "-pt"); + vpsd_ranking.add("selectionFailValue", 1000.0); + vpsd_ranking.add("selection", "algoIs(\"kChargedPFCandidate\")"); + vpsd_ranking.add("name", "ChargedPFCandidate"); + vpsd_ranking.add("plugin", "PFRecoTauChargedHadronStringQuality"); + desc.addVPSet("ranking", vpsd_ranking); + } + + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "pt > 0.5"); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + + { + edm::ParameterSetDescription vpsd_builders; + vpsd_builders.add("minMergeChargedHadronPt"); + vpsd_builders.add("name"); + vpsd_builders.add("plugin"); + vpsd_builders.addOptional("dRcone"); + vpsd_builders.addOptional("dRconeLimitedToJetArea"); + vpsd_builders.addOptional("dRmergeNeutralHadron"); + vpsd_builders.addOptional("dRmergePhoton"); + vpsd_builders.addOptional("srcTracks"); + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + vpsd_builders.add("qualityCuts", pset_qualityCuts); + } + + vpsd_builders.add("minMergeGammaEt"); + vpsd_builders.add("verbosity", 0); + vpsd_builders.add("minMergeNeutralHadronEt"); + + vpsd_builders.addOptional("dRmergePhotonWrtChargedHadron"); + vpsd_builders.addOptional("dRmergePhotonWrtNeutralHadron"); + vpsd_builders.addOptional("maxUnmatchedBlockElementsNeutralHadron"); + vpsd_builders.addOptional("dRmergePhotonWrtElectron"); + vpsd_builders.addOptional>("chargedHadronCandidatesParticleIds"); + vpsd_builders.addOptional("minBlockElementMatchesPhoton"); + vpsd_builders.addOptional("dRmergeNeutralHadronWrtNeutralHadron"); + vpsd_builders.addOptional("maxUnmatchedBlockElementsPhoton"); + vpsd_builders.addOptional("dRmergeNeutralHadronWrtOther"); + vpsd_builders.addOptional("dRmergeNeutralHadronWrtElectron"); + vpsd_builders.addOptional("minBlockElementMatchesNeutralHadron"); + vpsd_builders.addOptional("dRmergePhotonWrtOther"); + vpsd_builders.addOptional("dRmergeNeutralHadronWrtChargedHadron"); + + desc.addVPSet("builders", vpsd_builders); + } + + descriptions.add("ak4PFJetsRecoTauChargedHadrons", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(PFRecoTauChargedHadronProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauCorrectedInvariantMassProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauCorrectedInvariantMassProducer.cc index 61a14508804e8..e2c7a8c33b731 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauCorrectedInvariantMassProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauCorrectedInvariantMassProducer.cc @@ -19,17 +19,21 @@ #include "DataFormats/TauReco/interface/PFTauDecayMode.h" #include "DataFormats/TauReco/interface/PFTauDecayModeAssociation.h" +#include +#include + namespace { using namespace reco; class PFRecoTauCorrectedInvariantMassProducer : public PFTauDiscriminationProducerBase { public: - explicit PFRecoTauCorrectedInvariantMassProducer(const edm::ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig){ + explicit PFRecoTauCorrectedInvariantMassProducer(const edm::ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig){ PFTauDecayModeProducer_ = iConfig.getParameter("PFTauDecayModeProducer"); } ~PFRecoTauCorrectedInvariantMassProducer() override{} double discriminate(const PFTauRef& pfTau) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& evtSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::InputTag PFTauDecayModeProducer_; edm::Handle theDMAssoc; @@ -46,5 +50,17 @@ double PFRecoTauCorrectedInvariantMassProducer::discriminate(const PFTauRef& the const PFTauDecayMode& theDecayMode = (*theDMAssoc)[thePFTauRef]; return theDecayMode.mass(); } + +void +PFRecoTauCorrectedInvariantMassProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauCorrectedInvariantMassProducer + edm::ParameterSetDescription desc; + desc.add("PFTauDecayModeProducer"); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("pfRecoTauCorrectedInvariantMassProducer", desc); +} + } DEFINE_FWK_MODULE(PFRecoTauCorrectedInvariantMassProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDecayModeIndexProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDecayModeIndexProducer.cc index 77f6379357f29..1c1e29f82fc65 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDecayModeIndexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDecayModeIndexProducer.cc @@ -9,6 +9,9 @@ * */ +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "DataFormats/TauReco/interface/PFTauDecayMode.h" @@ -26,6 +29,7 @@ class PFRecoTauDecayModeIndexProducer final : public PFTauDiscriminationProducer ~PFRecoTauDecayModeIndexProducer() override{} double discriminate(const PFTauRef& thePFTauRef) const override ; void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::InputTag PFTauDecayModeProducer_; edm::Handle decayModes_; // holds the PFTauDecayModes for the current event @@ -54,4 +58,18 @@ double PFRecoTauDecayModeIndexProducer::discriminate(const PFTauRef& thePFTauRef } +void +PFRecoTauDecayModeIndexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfTauDecayModeIndexProducer + edm::ParameterSetDescription desc; + desc.add("PFTauDecayModeProducer", edm::InputTag("pfRecoTauDecayModeProducer")); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + descriptions.add("pfTauDecayModeIndexProducer", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDecayModeIndexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc index 9062d88608105..502fd4ce0f825 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron.cc @@ -4,6 +4,9 @@ * Authorss : Chi Nhan Nguyen (Texas A&M) */ +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -59,6 +62,8 @@ class PFRecoTauDiscriminationAgainstElectron final : public PFTauDiscriminationP double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + ~PFRecoTauDiscriminationAgainstElectron() override{} private: @@ -242,4 +247,51 @@ PFRecoTauDiscriminationAgainstElectron::isInEcalCrack(double eta) const } } +void +PFRecoTauDiscriminationAgainstElectron::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstElectron + edm::ParameterSetDescription desc; + desc.add("ApplyCut_ElectronPreID_2D", false); + desc.add("ElecPreID0_HOverPLead_minValue", 0.05); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + desc.add("ApplyCut_ElectronPreID", false); + desc.add("ApplyCut_HcalTotOverPLead", false); + desc.add("EOverPLead_minValue", 0.8); + desc.add("ElecPreID1_EOverPLead_maxValue", 0.8); + desc.add("HcalMaxOverPLead_minValue", 0.1); + desc.add("BremCombined_HOP", 0.1); + desc.add("ApplyCut_EmFraction", false); + desc.add("EmFraction_maxValue", 0.9); + desc.add("BremCombined_Mass", 0.55); + desc.add("ApplyCut_PFElectronMVA", true); + desc.add("PFElectronMVA_maxValue", -0.1); + desc.add("ApplyCut_HcalMaxOverPLead", false); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("ApplyCut_BremCombined", false); + desc.add("Hcal3x3OverPLead_minValue", 0.1); + desc.add("ElecPreID1_HOverPLead_minValue", 0.15); + desc.add("ElecPreID0_EOverPLead_maxValue", 0.95); + desc.add("BremsRecoveryEOverPLead_minValue", 0.8); + desc.add("ApplyCut_EcalCrackCut", false); + desc.add("BremCombined_StripSize", 0.03); + desc.add("EOverPLead_maxValue", 1.8); + desc.add("HcalTotOverPLead_minValue", 0.1); + desc.add("ApplyCut_BremsRecoveryEOverPLead", false); + desc.add("ApplyCut_Hcal3x3OverPLead", false); + desc.add("ApplyCut_EOverPLead", false); + desc.add("BremCombined_Fraction", 0.99); + desc.add("BremsRecoveryEOverPLead_maxValue", 1.8); + descriptions.add("pfRecoTauDiscriminationAgainstElectron", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron2.cc index 755e9507a24ac..09d64bda36a69 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectron2.cc @@ -6,6 +6,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "RecoTauTag/RecoTau/interface/AntiElectronIDCut2.h" @@ -58,8 +61,7 @@ class PFRecoTauDiscriminationAgainstElectron2 : public PFTauDiscriminationProduc etaCracks_string_ = iConfig.getParameter>("etaCracks"); - verbosity_ = ( iConfig.exists("verbosity") ) ? - iConfig.getParameter("verbosity") : 0; + verbosity_ = iConfig.getParameter("verbosity"); cuts2_ = new AntiElectronIDCut2(); } @@ -71,6 +73,7 @@ class PFRecoTauDiscriminationAgainstElectron2 : public PFTauDiscriminationProduc ~PFRecoTauDiscriminationAgainstElectron2() override { } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool isInEcalCrack(double) const; std::vector etaCracks_; @@ -192,4 +195,53 @@ PFRecoTauDiscriminationAgainstElectron2::isInEcalCrack(double eta) const (eta>1.460 && eta<1.558)); } +void +PFRecoTauDiscriminationAgainstElectron2::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstElectron2 + edm::ParameterSetDescription desc; + desc.add("rejectTausInEcalCrack", false); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + desc.add("applyCut_GammaEnFrac", true); + desc.add("applyCut_HLTSpecific", true); + desc.add("GammaEnFrac_barrel_max", 0.15); + desc.add("keepTausInEcalCrack", true); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("applyCut_GammaPhiMom", false); + desc.add("GammaPhiMom_endcap_max", 1.5); + desc.add("GammaPhiMom_barrel_max", 1.5); + desc.add("applyCut_leadPFChargedHadrEoP", true); + desc.add("LeadPFChargedHadrEoP_barrel_max", 1.01); + desc.add("GammaEtaMom_endcap_max", 1.5); + desc.add("GammaEtaMom_barrel_max", 1.5); + desc.add("Hcal3x3OverPLead_endcap_max", 0.1); + desc.add("LeadPFChargedHadrEoP_barrel_min", 0.99); + desc.add("LeadPFChargedHadrEoP_endcap_max2", 1.01); + desc.add("LeadPFChargedHadrEoP_endcap_min1", 0.7); + desc.add("LeadPFChargedHadrEoP_endcap_min2", 0.99); + desc.add("LeadPFChargedHadrEoP_endcap_max1", 1.3); + desc.add("verbosity", 0); + desc.add("GammaEnFrac_endcap_max", 0.2); + desc.add("applyCut_hcal3x3OverPLead", true); + desc.add("applyCut_GammaEtaMom", false); + desc.add>("etaCracks", { + "0.0:0.018", + "0.423:0.461", + "0.770:0.806", + "1.127:1.163", + "1.460:1.558", + }); + desc.add("Hcal3x3OverPLead_barrel_max", 0.2); + descriptions.add("pfRecoTauDiscriminationAgainstElectron2", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron2); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc index 90135a6bd6536..f3c1fe6168058 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronDeadECAL.cc @@ -16,6 +16,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Framework/interface/ESHandle.h" +#include +#include + #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h" #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" @@ -43,8 +46,7 @@ class PFRecoTauDiscriminationAgainstElectronDeadECAL : public PFTauDiscriminatio minStatus_ = cfg.getParameter("minStatus"); dR_ = cfg.getParameter("dR"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); } ~PFRecoTauDiscriminationAgainstElectronDeadECAL() override {} @@ -77,6 +79,8 @@ class PFRecoTauDiscriminationAgainstElectronDeadECAL : public PFTauDiscriminatio return discriminator; } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: void updateBadTowers(const edm::EventSetup& es) { @@ -176,4 +180,34 @@ class PFRecoTauDiscriminationAgainstElectronDeadECAL : public PFTauDiscriminatio int verbosity_; }; +void +PFRecoTauDiscriminationAgainstElectronDeadECAL::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstElectronDeadECAL + edm::ParameterSetDescription desc; + desc.add("verbosity", 0); + { + edm::ParameterSetDescription pset_Prediscriminants; + pset_Prediscriminants.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("leadTrack", psd1); + } + { + // encountered this at + // RecoTauTag/Configuration/python/HPSPFTaus_cff.py + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("decayMode", psd1); + } + desc.add("Prediscriminants", pset_Prediscriminants); + } + desc.add("dR", 0.08); + desc.add("PFTauProducer", edm::InputTag("pfTauProducer")); + desc.add("minStatus", 12); + descriptions.add("pfRecoTauDiscriminationAgainstElectronDeadECAL", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronDeadECAL); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc index f4e453013c418..06a1499845451 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA5.cc @@ -7,6 +7,9 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "RecoTauTag/RecoTau/interface/AntiElectronIDMVA5.h" @@ -39,8 +42,7 @@ class PFRecoTauDiscriminationAgainstElectronMVA5 : public PFTauDiscriminationPro srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); GsfElectrons_token = consumes(srcGsfElectrons_); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); // add category index produces("category"); @@ -57,6 +59,7 @@ class PFRecoTauDiscriminationAgainstElectronMVA5 : public PFTauDiscriminationPro delete mva_; } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool isInEcalCrack(double) const; @@ -237,4 +240,60 @@ PFRecoTauDiscriminationAgainstElectronMVA5::isInEcalCrack(double eta) const return (absEta > 1.460 && absEta < 1.558); } +void +PFRecoTauDiscriminationAgainstElectronMVA5::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstElectronMVA5 + edm::ParameterSetDescription desc; + desc.add("minMVANoEleMatchWOgWOgsfBL", 0.0); + desc.add("PFTauProducer", edm::InputTag("pfTauProducer")); + desc.add("mvaName_woGwoGSF_EC", "gbr_woGwoGSF_EC"); + desc.add("minMVANoEleMatchWgWOgsfBL", 0.0); + desc.add("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC"); + desc.add("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC"); + desc.add("minMVAWgWgsfBL", 0.0); + desc.add("minMVAWgWOgsfBL", 0.0); + desc.add("minMVANoEleMatchWgWgsfBL", 0.0); + desc.add("minMVAWOgWgsfEC", 0.0); + desc.add("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL"); + desc.add("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL"); + desc.add("returnMVA", true); + desc.add("minMVANoEleMatchWgWOgsfEC", 0.0); + desc.add("loadMVAfromDB", true); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("mvaName_wGwoGSF_EC", "gbr_wGwoGSF_EC"); + desc.add("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL"); + desc.add("minMVAWOgWOgsfEC", 0.0); + desc.add("mvaName_woGwoGSF_BL", "gbr_woGwoGSF_BL"); + desc.add("mvaName_wGwoGSF_BL", "gbr_wGwoGSF_BL"); + desc.add("minMVANoEleMatchWOgWOgsfEC", 0.0); + desc.add("mvaName_NoEleMatch_woGwGSF_BL", "gbr_NoEleMatch_woGwGSF_BL"); + desc.add("minMVANoEleMatchWgWgsfEC", 0.0); + desc.add("minMVAWOgWgsfBL", 0.0); + desc.add("minMVANoEleMatchWOgWgsfEC", 0.0); + desc.add("minMVAWgWOgsfEC", 0.0); + desc.add("mvaName_NoEleMatch_wGwGSF_EC", "gbr_NoEleMatch_wGwGSF_EC"); + desc.add("minMVAWgWgsfEC", 0.0); + desc.add("verbosity", 0); + desc.add("minMVANoEleMatchWOgWgsfBL", 0.0); + desc.add("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC"); + desc.add("method", "BDTG"); + desc.add("mvaName_NoEleMatch_wGwGSF_BL", "gbr_NoEleMatch_wGwGSF_BL"); + desc.add("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL"); + desc.add("srcGsfElectrons", edm::InputTag("gedGsfElectrons")); + desc.add("minMVAWOgWOgsfBL", 0.0); + desc.add("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC"); + desc.add("mvaName_NoEleMatch_woGwGSF_EC", "gbr_NoEleMatch_woGwGSF_EC"); + descriptions.add("pfRecoTauDiscriminationAgainstElectronMVA5", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA5); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc index 4e8a68a7a272e..b76da8b014122 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstElectronMVA6.cc @@ -7,6 +7,9 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "RecoTauTag/RecoTau/interface/AntiElectronIDMVA6.h" @@ -37,8 +40,8 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro srcGsfElectrons_ = cfg.getParameter("srcGsfElectrons"); GsfElectrons_token = consumes(srcGsfElectrons_); vetoEcalCracks_ = cfg.getParameter("vetoEcalCracks"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + + verbosity_ = cfg.getParameter("verbosity"); // add category index produces("category"); @@ -52,6 +55,8 @@ class PFRecoTauDiscriminationAgainstElectronMVA6 : public PFTauDiscriminationPro ~PFRecoTauDiscriminationAgainstElectronMVA6() override {} + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: bool isInEcalCrack(double) const; @@ -234,4 +239,54 @@ PFRecoTauDiscriminationAgainstElectronMVA6::isInEcalCrack(double eta) const return (absEta > 1.460 && absEta < 1.558); } +void +PFRecoTauDiscriminationAgainstElectronMVA6::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstElectronMVA6 + edm::ParameterSetDescription desc; + desc.add("minMVANoEleMatchWOgWOgsfBL", 0.0); + desc.add("PFTauProducer", edm::InputTag("pfTauProducer")); + desc.add("minMVANoEleMatchWgWOgsfBL", 0.0); + desc.add("mvaName_wGwGSF_EC", "gbr_wGwGSF_EC"); + desc.add("minMVAWgWgsfBL", 0.0); + desc.add("mvaName_woGwGSF_EC", "gbr_woGwGSF_EC"); + desc.add("minMVAWOgWgsfEC", 0.0); + desc.add("mvaName_wGwGSF_BL", "gbr_wGwGSF_BL"); + desc.add("mvaName_woGwGSF_BL", "gbr_woGwGSF_BL"); + desc.add("returnMVA", true); + desc.add("loadMVAfromDB", true); + { + edm::ParameterSetDescription pset_Prediscriminants; + pset_Prediscriminants.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("leadTrack", psd1); + } + { + // encountered this at + // RecoTauTag/Configuration/python/HPSPFTaus_cff.py + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("decayMode", psd1); + } + desc.add("Prediscriminants", pset_Prediscriminants); + } + desc.add("mvaName_NoEleMatch_woGwoGSF_BL", "gbr_NoEleMatch_woGwoGSF_BL"); + desc.add("vetoEcalCracks", true); + desc.add("usePhiAtEcalEntranceExtrapolation", false); + desc.add("mvaName_NoEleMatch_wGwoGSF_BL", "gbr_NoEleMatch_wGwoGSF_BL"); + desc.add("minMVANoEleMatchWOgWOgsfEC", 0.0); + desc.add("minMVAWOgWgsfBL", 0.0); + desc.add("minMVAWgWgsfEC", 0.0); + desc.add("verbosity", 0); + desc.add("mvaName_NoEleMatch_wGwoGSF_EC", "gbr_NoEleMatch_wGwoGSF_EC"); + desc.add("method", "BDTG"); + desc.add("srcGsfElectrons", edm::InputTag("gedGsfElectrons")); + desc.add("mvaName_NoEleMatch_woGwoGSF_EC", "gbr_NoEleMatch_woGwoGSF_EC"); + desc.add("minMVANoEleMatchWgWOgsfEC", 0.0); + descriptions.add("pfRecoTauDiscriminationAgainstElectronMVA6", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectronMVA6); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc index 109e06d98e67f..3fce88078a04c 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc @@ -5,6 +5,9 @@ * Authors : Sho Maruyama,M.Bachtis */ +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" @@ -28,14 +31,16 @@ class PFRecoTauDiscriminationAgainstMuon : public PFTauDiscriminationProducerBas a = iConfig.getParameter("a"); b = iConfig.getParameter("b"); c = iConfig.getParameter("c"); - maxNumberOfMatches_ = iConfig.exists("maxNumberOfMatches") ? iConfig.getParameter("maxNumberOfMatches") : 0; - checkNumMatches_ = iConfig.exists("checkNumMatches") ? iConfig.getParameter("checkNumMatches") : false; + maxNumberOfMatches_ = iConfig.getParameter("maxNumberOfMatches"); + checkNumMatches_ = iConfig.getParameter("checkNumMatches"); } ~PFRecoTauDiscriminationAgainstMuon() override {} double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string discriminatorOption_; double hop_; @@ -95,4 +100,30 @@ double PFRecoTauDiscriminationAgainstMuon::discriminate(const PFTauRef& thePFTau return (decision ? 1. : 0.); } +void +PFRecoTauDiscriminationAgainstMuon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstMuon + edm::ParameterSetDescription desc; + desc.add("a", 0.5); + desc.add("c", 0.0); + desc.add("b", 0.5); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("discriminatorOption", "noSegMatch"); + desc.add("HoPMin", 0.2); + desc.add("maxNumberOfMatches", 0); + desc.add("checkNumMatches", false); + descriptions.add("pfRecoTauDiscriminationAgainstMuon", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc index 2484150158f30..5691d69debbef 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon2.cc @@ -11,6 +11,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/MuonReco/interface/MuonChamberMatch.h" @@ -43,16 +46,14 @@ class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProd else throw edm::Exception(edm::errors::UnimplementedFeature) << " Invalid Configuration parameter 'discriminatorOption' = " << discriminatorOption_string << " !!\n"; hop_ = cfg.getParameter("HoPMin"); - maxNumberOfMatches_ = cfg.exists("maxNumberOfMatches") ? cfg.getParameter("maxNumberOfMatches"): 0; - doCaloMuonVeto_ = cfg.exists("doCaloMuonVeto") ? cfg.getParameter("doCaloMuonVeto"): false; - maxNumberOfHitsLast2Stations_ = cfg.exists("maxNumberOfHitsLast2Stations") ? cfg.getParameter("maxNumberOfHitsLast2Stations"): 0; - if ( cfg.exists("srcMuons") ) { + maxNumberOfMatches_ = cfg.getParameter("maxNumberOfMatches"); + doCaloMuonVeto_ = cfg.getParameter("doCaloMuonVeto"); + maxNumberOfHitsLast2Stations_ = cfg.getParameter("maxNumberOfHitsLast2Stations"); srcMuons_ = cfg.getParameter("srcMuons"); Muons_token = consumes(srcMuons_); dRmuonMatch_ = cfg.getParameter("dRmuonMatch"); dRmuonMatchLimitedToJetArea_ = cfg.getParameter("dRmuonMatchLimitedToJetArea"); minPtMatchedMuon_ = cfg.getParameter("minPtMatchedMuon"); - } typedef std::vector vint; maskMatchesDT_ = cfg.getParameter("maskMatchesDT"); maskMatchesCSC_ = cfg.getParameter("maskMatchesCSC"); @@ -62,7 +63,7 @@ class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProd maskHitsRPC_ = cfg.getParameter("maskHitsRPC"); numWarnings_ = 0; maxWarnings_ = 3; - verbosity_ = cfg.exists("verbosity") ? cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); } ~PFRecoTauDiscriminationAgainstMuon2() override {} @@ -70,6 +71,8 @@ class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProd double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; int discriminatorOption_; @@ -96,7 +99,7 @@ class PFRecoTauDiscriminationAgainstMuon2 final : public PFTauDiscriminationProd void PFRecoTauDiscriminationAgainstMuon2::beginEvent(const edm::Event& evt, const edm::EventSetup& es) { - if ( srcMuons_.label() != "" ) { + if ( !srcMuons_.label().empty() ) { evt.getByToken(Muons_token, muons_); } } @@ -184,7 +187,7 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p } } - if ( srcMuons_.label() != "" ) { + if ( !srcMuons_.label().empty() ) { size_t numMuons = muons_->size(); for ( size_t idxMuon = 0; idxMuon < numMuons; ++idxMuon ) { reco::MuonRef muon(muons_, idxMuon); @@ -280,4 +283,81 @@ double PFRecoTauDiscriminationAgainstMuon2::discriminate(const reco::PFTauRef& p } +void +PFRecoTauDiscriminationAgainstMuon2::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstMuon2 + edm::ParameterSetDescription desc; + desc.add>("maskHitsRPC", { + 0, + 0, + 0, + 0, + }); + desc.add("maxNumberOfHitsLast2Stations", 0); + desc.add>("maskMatchesRPC", { + 0, + 0, + 0, + 0, + }); + desc.add>("maskMatchesCSC", { + 1, + 0, + 0, + 0, + }); + desc.add>("maskHitsCSC", { + 0, + 0, + 0, + 0, + }); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + desc.add("verbosity", 0); + desc.add>("maskMatchesDT", { + 0, + 0, + 0, + 0, + }); + desc.add("minPtMatchedMuon", 5.0); + desc.add("dRmuonMatchLimitedToJetArea", false); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); //, 0.5); + psd1.add("Producer"); //, edm::InputTag("pfRecoTauDiscriminationByLeadingTrackFinding")); + psd0.addOptional("leadTrack", psd1); // optional with default? + } + // Prediscriminants can be + // Prediscriminants = noPrediscriminants, + // as in RecoTauTag/Configuration/python/HPSPFTaus_cff.py + // + // and the definition is: + // RecoTauTag/RecoTau/python/TauDiscriminatorTools.py + // # Require no prediscriminants + // noPrediscriminants = cms.PSet( + // BooleanOperator = cms.string("and"), + // ) + // -- so this is the minimum required definition + // otherwise it inserts the leadTrack with Producer = InpuTag(...) and does not find the corresponding output during the run + desc.add("Prediscriminants", psd0); + } + desc.add>("maskHitsDT", { + 0, + 0, + 0, + 0, + }); + desc.add("HoPMin", 0.2); + desc.add("maxNumberOfMatches", 0); + desc.add("discriminatorOption", "loose"); + desc.add("dRmuonMatch", 0.3); + desc.add("srcMuons", edm::InputTag("muons")); + desc.add("doCaloMuonVeto", false); + descriptions.add("pfRecoTauDiscriminationAgainstMuon2", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon2); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc index 6d1edbe9e06ec..f3bf6b8601213 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuonMVA.cc @@ -17,6 +17,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" @@ -72,11 +75,9 @@ class PFRecoTauDiscriminationAgainstMuonMVA final : public PFTauDiscriminationPr mvaInput_(nullptr) { mvaName_ = cfg.getParameter("mvaName"); - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; } mvaInput_ = new float[11]; @@ -84,8 +85,7 @@ class PFRecoTauDiscriminationAgainstMuonMVA final : public PFTauDiscriminationPr Muons_token=consumes(srcMuons_); dRmuonMatch_ = cfg.getParameter("dRmuonMatch"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); produces("category"); } @@ -106,6 +106,8 @@ class PFRecoTauDiscriminationAgainstMuonMVA final : public PFTauDiscriminationPr } } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; @@ -244,4 +246,31 @@ void PFRecoTauDiscriminationAgainstMuonMVA::endEvent(edm::Event& evt) } +void +PFRecoTauDiscriminationAgainstMuonMVA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstMuonMVA + edm::ParameterSetDescription desc; + desc.add("mvaMin", 0.0); + desc.add("mvaName", "againstMuonMVA"); + desc.add("PFTauProducer", edm::InputTag("pfTauProducer")); + desc.add("verbosity", 0); + desc.add("returnMVA", true); + desc.add("inputFileName", edm::FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile")); + desc.add("loadMVAfromDB", true); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("dRmuonMatch", 0.3); + desc.add("srcMuons", edm::InputTag("muons")); + descriptions.add("pfRecoTauDiscriminationAgainstMuonMVA", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuonMVA); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc index c444676d5a9be..0fda0a4f29dbb 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByCharge.cc @@ -1,3 +1,6 @@ +#include +#include + #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" /* class PFRecoTauDiscriminationByCharge @@ -19,6 +22,7 @@ class PFRecoTauDiscriminationByCharge : public PFTauDiscriminationProducerBase } ~PFRecoTauDiscriminationByCharge() override{} double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: uint32_t chargeReq_; bool oneOrThreeProng_; @@ -32,4 +36,20 @@ double PFRecoTauDiscriminationByCharge::discriminate(const PFTauRef& thePFTauRef return ( (chargeok && oneOrThreeProngOK) ? 1. : 0. ); } + +void +PFRecoTauDiscriminationByCharge::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByCharge + edm::ParameterSetDescription desc; + desc.add("AbsChargeReq", 1); + desc.add("ApplyOneOrThreeProngCut", false); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducerHighEfficiency")); + descriptions.add("pfRecoTauDiscriminationByCharge", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByCharge); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc index 5045b4b93d416..c6268abe75a43 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByDeltaE.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class PFRecoTauDiscriminationByDeltaE * created : August 30 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -27,6 +30,7 @@ class PFRecoTauDiscriminationByDeltaE : public PFTauDiscriminationProducerBase void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double DeltaE(const PFTauRef&) const ; @@ -66,5 +70,26 @@ double PFRecoTauDiscriminationByDeltaE::DeltaE(const PFTauRef& tau) const { } } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationByDeltaE); +void +PFRecoTauDiscriminationByDeltaE::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByDeltaE + edm::ParameterSetDescription desc; + desc.add("deltaEmin", -0.15); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("deltaEmax", 1.0); + desc.add("BooleanOutput", true); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + descriptions.add("pfRecoTauDiscriminationByDeltaE", desc); +} +DEFINE_FWK_MODULE(PFRecoTauDiscriminationByDeltaE); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc index d033c30d66b4d..98da3dc8ab216 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByFlightPathSignificance.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class PFRecoTauDiscriminationByFlightPathSignificance * created : August 30 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -38,6 +41,7 @@ class PFRecoTauDiscriminationByFlightPathSignificance void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double threeProngFlightPathSig(const PFTauRef&) const ; double vertexSignificance(reco::Vertex const&,reco::Vertex const &,GlobalVector const&) const; @@ -118,5 +122,27 @@ double PFRecoTauDiscriminationByFlightPathSignificance::vertexSignificance( return SecondaryVertex::computeDist3d(pv,sv,direction,withPVError).significance(); } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationByFlightPathSignificance); +void +PFRecoTauDiscriminationByFlightPathSignificance::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByFlightPathSignificance + edm::ParameterSetDescription desc; + desc.add("flightPathSig", 1.5); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("BooleanOutput", true); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("UsePVerror", true); + descriptions.add("pfRecoTauDiscriminationByFlightPathSignificance", desc); +} +DEFINE_FWK_MODULE(PFRecoTauDiscriminationByFlightPathSignificance); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc index 8b98b95f52ad9..e2d77e24954b4 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByHPSSelection.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + #include "CommonTools/Utils/interface/StringObjectFunction.h" #include "DataFormats/Math/interface/deltaR.h" @@ -23,6 +26,8 @@ class PFRecoTauDiscriminationByHPSSelection : public PFTauDiscriminationProducer ~PFRecoTauDiscriminationByHPSSelection() override; double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: typedef StringObjectFunction TauFunc; @@ -71,34 +76,17 @@ PFRecoTauDiscriminationByHPSSelection::PFRecoTauDiscriminationByHPSSelection(con for(auto const& decayMode : decayModes ) { // The mass window(s) DecayModeCuts cuts; - if ( decayMode.exists("nTracksMin") ) { - cuts.nTracksMin_ = decayMode.getParameter("nTracksMin"); - } else { - cuts.nTracksMin_ = 0; - } - if ( decayMode.exists("nChargedPFCandsMin") ) { - cuts.nChargedPFCandsMin_ = decayMode.getParameter("nChargedPFCandsMin"); - } else { - cuts.nChargedPFCandsMin_ = 0; - } + cuts.nTracksMin_ = decayMode.getParameter("nTracksMin"); + cuts.nChargedPFCandsMin_ = decayMode.getParameter("nChargedPFCandsMin"); cuts.minMass_ = decayMode.getParameter("minMass"); cuts.maxMass_ = new TauFunc(decayMode.getParameter("maxMass")); edm::ParameterSet applyBendCorrection = decayMode.getParameter("applyBendCorrection"); cuts.applyBendCorrection_eta_ = applyBendCorrection.getParameter("eta"); cuts.applyBendCorrection_phi_ = applyBendCorrection.getParameter("phi"); cuts.applyBendCorrection_mass_ = applyBendCorrection.getParameter("mass"); - if ( decayMode.exists("minPi0Mass") ) { - cuts.minPi0Mass_ = decayMode.getParameter("minPi0Mass"); - cuts.maxPi0Mass_ = decayMode.getParameter("maxPi0Mass"); - } else { - cuts.minPi0Mass_ = -1.e3; - cuts.maxPi0Mass_ = 1.e9; - } - if ( decayMode.exists("assumeStripMass") ) { - cuts.assumeStripMass_ = decayMode.getParameter("assumeStripMass"); - } else { - cuts.assumeStripMass_ = -1.0; - } + cuts.minPi0Mass_ = decayMode.getParameter("minPi0Mass"); + cuts.maxPi0Mass_ = decayMode.getParameter("maxPi0Mass"); + cuts.assumeStripMass_ = decayMode.getParameter("assumeStripMass"); decayModeCuts_.insert(std::make_pair( // The decay mode as a key std::make_pair( @@ -109,8 +97,7 @@ PFRecoTauDiscriminationByHPSSelection::PFRecoTauDiscriminationByHPSSelection(con } requireTauChargedHadronsToBeChargedPFCands_ = pset.getParameter("requireTauChargedHadronsToBeChargedPFCands"); minPixelHits_ = pset.getParameter("minPixelHits"); - verbosity_ = pset.exists("verbosity") ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } @@ -338,4 +325,54 @@ PFRecoTauDiscriminationByHPSSelection::discriminate(const reco::PFTauRef& tau) c return 1.0; } +void +PFRecoTauDiscriminationByHPSSelection::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // hpsSelectionDiscriminator + edm::ParameterSetDescription desc; + desc.add("PFTauProducer", edm::InputTag("combinatoricRecoTaus")); + desc.add("verbosity", 0); + desc.add("minTauPt", 0.0); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + + { + edm::ParameterSetDescription vpset_decayModes; + vpset_decayModes.add("minPi0Mass", -1.e3); + vpset_decayModes.add("maxMass"); + vpset_decayModes.add("maxPi0Mass", 1.e9); + vpset_decayModes.add("nPiZeros"); + vpset_decayModes.add("minMass"); + vpset_decayModes.add("nChargedPFCandsMin", 0); + vpset_decayModes.add("nTracksMin", 0); + vpset_decayModes.add("nCharged"); + { + edm::ParameterSetDescription psd0; + psd0.add("phi"); + psd0.add("eta"); + psd0.add("mass"); + vpset_decayModes.add("applyBendCorrection", psd0); + } + vpset_decayModes.add("assumeStripMass", -1.0); + std::vector vpset_default; + { + edm::ParameterSet pset; + pset.addParameter("minPi0Mass", -1.e3); + pset.addParameter("maxPi0Mass", 1.e9); + pset.addParameter("nChargedPFCandsMin", 0); + pset.addParameter("nTracksMin", 0); + pset.addParameter("assumeStripMass", -1.0); + vpset_default.push_back(pset); + } + desc.addVPSet("decayModes", vpset_decayModes, vpset_default); + } + + desc.add("matchingCone", 0.5); + desc.add("minPixelHits", 1); + desc.add("requireTauChargedHadronsToBeChargedPFCands", false); + descriptions.add("hpsSelectionDiscriminator", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByHPSSelection); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc index 20db4e1d220c7..8f7a88ef19338 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByInvMass.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + /* class PFRecoTauDiscriminationByInvMass * created : August 30 2010, * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki) @@ -13,32 +16,29 @@ class PFRecoTauDiscriminationByInvMass: public PFTauDiscriminationProducerBase { explicit PFRecoTauDiscriminationByInvMass(const edm::ParameterSet& pset) :PFTauDiscriminationProducerBase(pset) { // If select is not set, just return the invariant mass - cut_ = pset.exists("select"); - if (cut_) { - const edm::ParameterSet &select = pset.getParameter - ("select"); - // Get default cuts - min_default_ = select.getParameter("min"); - max_default_ = select.getParameter("max"); - // Get decay mode specific cuts - std::vector decayModeCutNames = - select.getParameterNamesForType(); - for(auto const& dmName : decayModeCutNames) { - const edm::ParameterSet &dmPSet = - select.getParameter(dmName); - unsigned int nCharged = dmPSet.getParameter("charged"); - unsigned int nPiZero = dmPSet.getParameter("pizeros"); - double minCut = dmPSet.getParameter("min"); - double maxCut = dmPSet.getParameter("max"); - // Add our dm-specific cut to the map - decayModeCuts_[std::make_pair(nCharged, nPiZero)] = - std::make_pair(minCut, maxCut); - } + const edm::ParameterSet &select = pset.getParameter("select"); + // Get default cuts + min_default_ = select.getParameter("min"); + max_default_ = select.getParameter("max"); + // Get decay mode specific cuts + std::vector decayModeCutNames = + select.getParameterNamesForType(); + for(auto const& dmName : decayModeCutNames) { + const edm::ParameterSet &dmPSet = + select.getParameter(dmName); + unsigned int nCharged = dmPSet.getParameter("charged"); + unsigned int nPiZero = dmPSet.getParameter("pizeros"); + double minCut = dmPSet.getParameter("min"); + double maxCut = dmPSet.getParameter("max"); + // Add our dm-specific cut to the map + decayModeCuts_[std::make_pair(nCharged, nPiZero)] = + std::make_pair(minCut, maxCut); } } ~PFRecoTauDiscriminationByInvMass() override{} double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: typedef std::pair IntPair; typedef std::pair DoublePair; @@ -46,27 +46,48 @@ class PFRecoTauDiscriminationByInvMass: public PFTauDiscriminationProducerBase { DecayModeCutMap decayModeCuts_; double min_default_; double max_default_; - bool cut_; }; double PFRecoTauDiscriminationByInvMass::discriminate(const reco::PFTauRef& tau) const { double mass = tau->mass(); - if (cut_) { - unsigned int charged = tau->signalPFChargedHadrCands().size(); - unsigned int pizeros = tau->signalPiZeroCandidates().size(); - DecayModeCutMap::const_iterator specificCut = decayModeCuts_.find( - std::make_pair(charged, pizeros)); - // Cut does not exist for this decay mode - if (specificCut == decayModeCuts_.end() ) - return (mass > min_default_ && mass < max_default_); - else - return (mass > specificCut->second.first && - mass < specificCut->second.second); - } + unsigned int charged = tau->signalPFChargedHadrCands().size(); + unsigned int pizeros = tau->signalPiZeroCandidates().size(); + DecayModeCutMap::const_iterator specificCut = decayModeCuts_.find( + std::make_pair(charged, pizeros)); + // Cut does not exist for this decay mode + if (specificCut == decayModeCuts_.end() ) + return (mass > min_default_ && mass < max_default_); + else + return (mass > specificCut->second.first && + mass < specificCut->second.second); // If we dont' cut, just return the mass return mass; } -DEFINE_FWK_MODULE(PFRecoTauDiscriminationByInvMass); +void +PFRecoTauDiscriminationByInvMass::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByInvMass + edm::ParameterSetDescription desc; + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("max"); + psd0.add("min"); + desc.add("select", psd0); + } + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + descriptions.add("pfRecoTauDiscriminationByInvMass", desc); +} +DEFINE_FWK_MODULE(PFRecoTauDiscriminationByInvMass); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc index 43c3b598b9bad..fbeac1288625e 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByIsolation.cc @@ -7,6 +7,8 @@ #include "CommonTools/Utils/interface/StringCutObjectSelector.h" #include "CommonTools/Utils/interface/StringObjectFunction.h" #include "DataFormats/VertexReco/interface/Vertex.h" +#include +#include #include "TMath.h" #include "TFormula.h" @@ -36,18 +38,15 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas includeGammas_ = pset.getParameter( "ApplyDiscriminationByECALIsolation"); - calculateWeights_ = pset.exists("ApplyDiscriminationByWeightedECALIsolation") ? - pset.getParameter("ApplyDiscriminationByWeightedECALIsolation") : false; + calculateWeights_ = pset.getParameter("ApplyDiscriminationByWeightedECALIsolation"); // RIC: multiply neutral isolation by a flat factor. // Useful, for instance, to combine charged and neutral isolations // with different relative weights - weightGammas_ = pset.exists("WeightECALIsolation") ? - pset.getParameter("WeightECALIsolation") : 1.0; + weightGammas_ = pset.getParameter("WeightECALIsolation"); // RIC: allow to relax the isolation completely beyond a given tau pt - minPtForNoIso_ = pset.exists("minTauPtForNoIso") ? - pset.getParameter("minTauPtForNoIso") : -99.; + minPtForNoIso_ = pset.getParameter("minTauPtForNoIso"); applyOccupancyCut_ = pset.getParameter("applyOccupancyCut"); maximumOccupancy_ = pset.getParameter("maximumOccupancy"); @@ -55,23 +54,15 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas applySumPtCut_ = pset.getParameter("applySumPtCut"); maximumSumPt_ = pset.getParameter("maximumSumPtCut"); - applyRelativeSumPtCut_ = pset.getParameter( - "applyRelativeSumPtCut"); - maximumRelativeSumPt_ = pset.getParameter( - "relativeSumPtCut"); - offsetRelativeSumPt_ = pset.exists("relativeSumPtOffset") ? - pset.getParameter("relativeSumPtOffset") : 0.0; - - storeRawOccupancy_ = pset.exists("storeRawOccupancy") ? - pset.getParameter("storeRawOccupancy") : false; - storeRawSumPt_ = pset.exists("storeRawSumPt") ? - pset.getParameter("storeRawSumPt") : false; - storeRawPUsumPt_ = pset.exists("storeRawPUsumPt") ? - pset.getParameter("storeRawPUsumPt") : false; - storeRawFootprintCorrection_ = pset.exists("storeRawFootprintCorrection") ? - pset.getParameter("storeRawFootprintCorrection") : false; - storeRawPhotonSumPt_outsideSignalCone_ = pset.exists("storeRawPhotonSumPt_outsideSignalCone") ? - pset.getParameter("storeRawPhotonSumPt_outsideSignalCone") : false; + applyRelativeSumPtCut_ = pset.getParameter("applyRelativeSumPtCut"); + maximumRelativeSumPt_ = pset.getParameter("relativeSumPtCut"); + offsetRelativeSumPt_ = pset.getParameter("relativeSumPtOffset"); + + storeRawOccupancy_ = pset.getParameter("storeRawOccupancy"); + storeRawSumPt_ = pset.getParameter("storeRawSumPt"); + storeRawPUsumPt_ = pset.getParameter("storeRawPUsumPt"); + storeRawFootprintCorrection_ = pset.getParameter("storeRawFootprintCorrection"); + storeRawPhotonSumPt_outsideSignalCone_ = pset.getParameter("storeRawPhotonSumPt_outsideSignalCone"); // Sanity check on requested options. We can't apply cuts and store the // raw output at the same time @@ -103,21 +94,15 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas << " These options are mutually exclusive."; } - if ( pset.exists("customOuterCone") ) { - customIsoCone_ = pset.getParameter("customOuterCone"); - } else { - customIsoCone_ = -1; - } + customIsoCone_ = pset.getParameter("customOuterCone"); - applyPhotonPtSumOutsideSignalConeCut_ = ( pset.exists("applyPhotonPtSumOutsideSignalConeCut") ) ? - pset.getParameter("applyPhotonPtSumOutsideSignalConeCut") : false; + applyPhotonPtSumOutsideSignalConeCut_ = pset.getParameter("applyPhotonPtSumOutsideSignalConeCut"); if ( applyPhotonPtSumOutsideSignalConeCut_ ) { maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxAbsPhotonSumPt_outsideSignalCone"); maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter("maxRelPhotonSumPt_outsideSignalCone"); } - applyFootprintCorrection_ = ( pset.exists("applyFootprintCorrection") ) ? - pset.getParameter("applyFootprintCorrection") : false; + applyFootprintCorrection_ = pset.getParameter("applyFootprintCorrection"); if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) { edm::VParameterSet cfgFootprintCorrections = pset.getParameter("footprintCorrections"); for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin(); @@ -138,8 +123,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas vertexAssociator_.reset( new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector())); - applyDeltaBeta_ = pset.exists("applyDeltaBetaCorrection") ? - pset.getParameter("applyDeltaBetaCorrection") : false; + applyDeltaBeta_ = pset.getParameter("applyDeltaBetaCorrection"); if ( applyDeltaBeta_ || calculateWeights_ ) { // Factorize the isolation QCuts into those that are used to @@ -149,10 +133,13 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas // Determine the pt threshold for the PU tracks // First check if the user specifies explicitly the cut. - if ( pset.exists("deltaBetaPUTrackPtCutOverride") ) { + // For that the user has to provide a >= 0 value for the PtCutOverride. + bool deltaBetaPUTrackPtCutOverride = pset.getParameter("deltaBetaPUTrackPtCutOverride"); + if ( deltaBetaPUTrackPtCutOverride ) { + double deltaBetaPUTrackPtCutOverride_val = pset.getParameter("deltaBetaPUTrackPtCutOverride_val"); puFactorizedIsoQCuts.second.addParameter( "minTrackPt", - pset.getParameter("deltaBetaPUTrackPtCutOverride")); + deltaBetaPUTrackPtCutOverride_val); } else { // Secondly take it from the minGammaEt puFactorizedIsoQCuts.second.addParameter( @@ -178,8 +165,7 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas new TFormula("DB_corr", deltaBetaFactorFormula.c_str())); } - applyRhoCorrection_ = pset.exists("applyRhoCorrection") ? - pset.getParameter("applyRhoCorrection") : false; + applyRhoCorrection_ = pset.getParameter("applyRhoCorrection"); if ( applyRhoCorrection_ ) { rhoProducer_ = pset.getParameter("rhoProducer"); rho_token=consumes(rhoProducer_); @@ -187,11 +173,9 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas rhoUEOffsetCorrection_ = pset.getParameter("rhoUEOffsetCorrection"); } - useAllPFCands_ = pset.exists("UseAllPFCandsForWeights") ? - pset.getParameter("UseAllPFCandsForWeights") : false; + useAllPFCands_ = pset.getParameter("UseAllPFCandsForWeights"); - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } ~PFRecoTauDiscriminationByIsolation() override @@ -210,6 +194,8 @@ class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBas return out; } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; @@ -618,4 +604,147 @@ PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) const } } +void +PFRecoTauDiscriminationByIsolation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByIsolation + edm::ParameterSetDescription desc; + desc.add("storeRawFootprintCorrection", false); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + desc.add("storeRawOccupancy", false); + desc.add("maximumSumPtCut", 6.0); + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + } + + desc.add("minTauPtForNoIso", -99.0); + desc.add("maxAbsPhotonSumPt_outsideSignalCone", 1000000000.0); + desc.add("vertexSrc", edm::InputTag("offlinePrimaryVertices")); + desc.add("applySumPtCut", false); + desc.add("rhoConeSize", 0.5); + desc.add("ApplyDiscriminationByTrackerIsolation", true); + desc.add("storeRawPhotonSumPt_outsideSignalCone", false); + desc.add("rhoProducer", edm::InputTag("fixedGridRhoFastjetAll")); + + { + edm::ParameterSetDescription vpsd1; + vpsd1.add("selection"); + vpsd1.add("offset"); + desc.addVPSet("footprintCorrections", vpsd1); + } + + desc.add("deltaBetaFactor", "0.38"); + desc.add("applyFootprintCorrection", false); + desc.add("UseAllPFCandsForWeights", false); + desc.add("relativeSumPtCut", 0.0); + { + edm::ParameterSetDescription pset_Prediscriminants; + pset_Prediscriminants.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("leadTrack", psd1); + } + { + // encountered this at + // RecoTauTag/Configuration/python/HPSPFTaus_cff.py + // Prediscriminants = requireDecayMode.clone(), + // requireDecayMode = cms.PSet( + // BooleanOperator = cms.string("and"), + // decayMode = cms.PSet( + // Producer = cms.InputTag('hpsPFTauDiscriminationByDecayModeFindingNewDMs'), + // cut = cms.double(0.5) + // ) + // ) + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("decayMode", psd1); + } + { + // encountered this at + // RecoTauTag/Configuration/python/HPSPFTaus_cff.py + // Prediscriminants = requireDecayMode.clone(), + // hpsPFTauDiscriminationByLooseIsolation.Prediscriminants.preIso = cms.PSet( + // Producer = cms.InputTag("hpsPFTauDiscriminationByLooseChargedIsolation"), + // cut = cms.double(0.5) + // ) + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + pset_Prediscriminants.addOptional("preIso", psd1); + } + desc.add("Prediscriminants", pset_Prediscriminants); + } + + desc.add("maximumOccupancy", 0); + desc.add("verbosity", 0); + + desc.add("applyOccupancyCut", true); + desc.add("applyDeltaBetaCorrection", false); + desc.add("applyRelativeSumPtCut", false); + desc.add("storeRawPUsumPt", false); + desc.add("applyPhotonPtSumOutsideSignalConeCut", false); + desc.add("deltaBetaPUTrackPtCutOverride", false); + desc.add("ApplyDiscriminationByWeightedECALIsolation", false); + desc.add("storeRawSumPt", false); + desc.add("ApplyDiscriminationByECALIsolation", true); + desc.add("applyRhoCorrection", false); + + desc.add("WeightECALIsolation", 1.0); + desc.add("rhoUEOffsetCorrection", 1.0); + desc.add("maxRelPhotonSumPt_outsideSignalCone", 0.1); + desc.add("deltaBetaPUTrackPtCutOverride_val", -1.5); + desc.add("isoConeSizeForDeltaBeta", 0.5); + desc.add("relativeSumPtOffset", 0.0); + desc.add("customOuterCone", -1.0); + desc.add("particleFlowSrc", edm::InputTag("particleFlow")); + + descriptions.add("pfRecoTauDiscriminationByIsolation", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByIsolation); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc index 795fe580437b7..9123a604d92a5 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByLeadingObjectPtCut.cc @@ -1,4 +1,6 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include /* * class PFRecoTauDiscriminationByLeadingObjectPtCut @@ -17,6 +19,7 @@ class PFRecoTauDiscriminationByLeadingObjectPtCut : public PFTauDiscriminationPr } ~PFRecoTauDiscriminationByLeadingObjectPtCut() override{} double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool chargedOnly_; double minPtLeadObject_; @@ -50,6 +53,21 @@ double PFRecoTauDiscriminationByLeadingObjectPtCut::discriminate(const PFTauRef& return ( leadObjectPt > minPtLeadObject_ ? 1. : 0. ); } +void +PFRecoTauDiscriminationByLeadingObjectPtCut::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByLeadingObjectPtCut + edm::ParameterSetDescription desc; + desc.add("MinPtLeadingObject", 5.0); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + desc.add("UseOnlyChargedHadrons", false); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + descriptions.add("pfRecoTauDiscriminationByLeadingObjectPtCut", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByLeadingObjectPtCut); /* diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc index a9b40f0cdbe60..1774b66575d44 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolation2.cc @@ -17,6 +17,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" @@ -73,11 +76,9 @@ class PFRecoTauDiscriminationByIsolationMVA2 : public PFTauDiscriminationProduce category_output_() { mvaName_ = cfg.getParameter("mvaName"); - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; } std::string mvaOpt_string = cfg.getParameter("mvaOpt"); if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT; @@ -97,8 +98,7 @@ class PFRecoTauDiscriminationByIsolationMVA2 : public PFTauDiscriminationProduce NeutralIsoPtSum_token = consumes(cfg.getParameter("srcNeutralIsoPtSum")); PUcorrPtSum_token = consumes(cfg.getParameter("srcPUcorrPtSum")); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); produces("category"); } @@ -119,6 +119,7 @@ class PFRecoTauDiscriminationByIsolationMVA2 : public PFTauDiscriminationProduce } } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: std::string moduleLabel_; @@ -240,4 +241,25 @@ void PFRecoTauDiscriminationByIsolationMVA2::endEvent(edm::Event& evt) evt.put(std::move(category_output_), "category"); } +void +PFRecoTauDiscriminationByIsolationMVA2::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByIsolationMVA2 + edm::ParameterSetDescription desc; + + desc.add("mvaName"); + desc.add("loadMVAfromDB"); + desc.addOptional("inputFileName"); + desc.add("mvaOpt"); + + desc.add("srcTauTransverseImpactParameters"); + desc.add("srcChargedIsoPtSum"); + desc.add("srcNeutralIsoPtSum"); + desc.add("srcPUcorrPtSum"); + desc.add("verbosity", 0); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("pfRecoTauDiscriminationByIsolationMVA2", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByIsolationMVA2); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc index b499b06c86ab7..96c5c09f9ae65 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByMVAIsolationRun2.cc @@ -17,6 +17,9 @@ #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" @@ -75,11 +78,9 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd category_output_() { mvaName_ = cfg.getParameter("mvaName"); - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; } std::string mvaOpt_string = cfg.getParameter("mvaOpt"); if ( mvaOpt_string == "oldDMwoLT" ) mvaOpt_ = kOldDMwoLT; @@ -110,8 +111,7 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd PhotonPtSumOutsideSignalCone_token = consumes(cfg.getParameter("srcPhotonPtSumOutsideSignalCone")); FootprintCorrection_token = consumes(cfg.getParameter("srcFootprintCorrection")); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); produces("category"); } @@ -132,6 +132,7 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd } } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: std::string moduleLabel_; @@ -359,6 +360,33 @@ void PFRecoTauDiscriminationByMVAIsolationRun2::endEvent(edm::Event& evt) evt.put(std::move(category_output_), "category"); } + +void +PFRecoTauDiscriminationByMVAIsolationRun2::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByMVAIsolationRun2 + edm::ParameterSetDescription desc; + + desc.add("mvaName"); + desc.add("loadMVAfromDB"); + desc.addOptional("inputFileName"); + desc.add("mvaOpt"); + + desc.add("srcTauTransverseImpactParameters"); + desc.add("srcChargedIsoPtSum"); + desc.add("srcNeutralIsoPtSum"); + desc.add("srcPUcorrPtSum"); + + desc.add("srcPhotonPtSumOutsideSignalCone"); + desc.add("srcFootprintCorrection"); + + desc.add("verbosity", 0); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("pfRecoTauDiscriminationByMVAIsolationRun2", desc); +} + + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByMVAIsolationRun2); }} //namespace diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc index 6907c949952c5..32ceb75ac26d2 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByNProngs.cc @@ -1,5 +1,7 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h" #include "RecoTauTag/RecoTau/interface/RecoTauVertexAssociator.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -23,6 +25,7 @@ class PFRecoTauDiscriminationByNProngs : public PFTauDiscriminationProducerBase void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: std::unique_ptr qcuts_; std::unique_ptr vertexAssociator_; @@ -75,4 +78,69 @@ double PFRecoTauDiscriminationByNProngs::discriminate(const PFTauRef& tau) const return np; } +void +PFRecoTauDiscriminationByNProngs::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByNProngs + edm::ParameterSetDescription desc; + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + } + + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + desc.add("Prediscriminants", psd0); + } + + desc.add("BooleanOutput", true); + desc.add("PFTauProducer", edm::InputTag("combinatoricRecoTaus")); + desc.add("MinN", 1); + desc.add("MaxN", 0); + descriptions.add("pfRecoTauDiscriminationByNProngs", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByNProngs); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc index ddf6875d04638..6a70c94ad0c44 100755 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationByTauPolarization.cc @@ -1,3 +1,5 @@ +#include +#include #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" /* class PFRecoTauDiscriminationByTauPolarization @@ -24,6 +26,7 @@ class PFRecoTauDiscriminationByTauPolarization : void beginEvent(const Event&, const EventSetup&) override; double discriminate(const PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: bool booleanOutput; double rTauMin; @@ -47,4 +50,75 @@ PFRecoTauDiscriminationByTauPolarization::discriminate(const PFTauRef& tau) cons return rTau; } +void +PFRecoTauDiscriminationByTauPolarization::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationByTauPolarization + edm::ParameterSetDescription desc; + desc.add("rtau", 0.8); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("BooleanOutput", true); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + } + + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + + descriptions.add("pfRecoTauDiscriminationByTauPolarization", desc); +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationByTauPolarization); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc index 516463ed57416..fb60c8bc20245 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauEnergyAlgorithmPlugin.cc @@ -58,11 +58,9 @@ class PFRecoTauEnergyAlgorithmPlugin : public RecoTauModifierPlugin dRaddNeutralHadron_(cfg.getParameter("dRaddNeutralHadron")), minNeutralHadronEt_(cfg.getParameter("minNeutralHadronEt")), dRaddPhoton_(cfg.getParameter("dRaddPhoton")), - minGammaEt_(cfg.getParameter("minGammaEt")) -{ - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; -} + minGammaEt_(cfg.getParameter("minGammaEt")), + verbosity_(cfg.getParameter("verbosity")) +{} PFRecoTauEnergyAlgorithmPlugin::~PFRecoTauEnergyAlgorithmPlugin() {} diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauMassPlugin.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauMassPlugin.cc index 0747d9720e00b..af3c8fafa1889 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauMassPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauMassPlugin.cc @@ -39,8 +39,7 @@ class PFRecoTauMassPlugin : public RecoTauModifierPlugin PFRecoTauMassPlugin::PFRecoTauMassPlugin(const edm::ParameterSet& cfg, edm::ConsumesCollector &&iC) : RecoTauModifierPlugin(cfg, std::move(iC)) { - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); } PFRecoTauMassPlugin::~PFRecoTauMassPlugin() diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc index 8540bc371791d..a511f262e733a 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauProducer.cc @@ -17,6 +17,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" @@ -36,6 +39,7 @@ class PFRecoTauProducer : public EDProducer { explicit PFRecoTauProducer(const edm::ParameterSet& iConfig); ~PFRecoTauProducer() override; void produce(edm::Event&,const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::EDGetTokenT PFTauTagInfoProducer_; edm::InputTag ElectronPreIDProducer_; @@ -125,4 +129,67 @@ void PFRecoTauProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup iEvent.put(std::move(resultPFTau)); } +void +PFRecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauProducer + edm::ParameterSetDescription desc; + desc.add("Rphi", 2.0); + desc.add("LeadTrack_minPt", 0.0); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("ECALSignalConeSizeFormula", "0.15"); + desc.add("TrackerIsolConeMetric", "DR"); + desc.add("TrackerSignalConeMetric", "DR"); + desc.add("EcalStripSumE_deltaPhiOverQ_minValue", -0.1); + desc.add("smearedPVsigmaX", 0.0015); + desc.add("smearedPVsigmaY", 0.0015); + desc.add("MatchingConeMetric", "DR"); + desc.add("TrackerSignalConeSizeFormula", "0.07"); + desc.add("MatchingConeSizeFormula", "0.1"); + desc.add("TrackerIsolConeSize_min", 0.0); + desc.add("MatchingConeSize_min", 0.0); + desc.add("ElectronPreIDProducer", edm::InputTag("elecpreid")); + desc.add("ChargedHadrCandLeadChargedHadrCand_tksmaxDZ", 1.0); + desc.add("TrackerIsolConeSize_max", 0.6); + desc.add("TrackerSignalConeSize_max", 0.07); + desc.add("HCALIsolConeMetric", "DR"); + desc.add("AddEllipseGammas", false); + desc.add("maximumForElectrionPreIDOutput", -0.1); + desc.add("TrackerSignalConeSize_min", 0.0); + desc.add("JetPtMin", 0.0); + desc.add("HCALIsolConeSizeFormula", "0.50"); + desc.add("AreaMetric_recoElements_maxabsEta", 2.5); + desc.add("HCALIsolConeSize_max", 0.6); + desc.add("Track_IsolAnnulus_minNhits", 3); + desc.add("HCALSignalConeMetric", "DR"); + desc.add("ElecPreIDLeadTkMatch_maxDR", 0.01); + desc.add("PFTauTagInfoProducer", edm::InputTag("pfRecoTauTagInfoProducer")); + desc.add("ECALIsolConeMetric", "DR"); + desc.add("ECALIsolConeSizeFormula", "0.50"); + desc.add("UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint", true); + desc.add("Algorithm", "ConeBased"); + desc.add("ECALIsolConeSize_max", 0.6); + desc.add("ECALSignalConeMetric", "DR"); + desc.add("EcalStripSumE_deltaPhiOverQ_maxValue", 0.5); + desc.add("HCALSignalConeSize_max", 0.6); + desc.add("ECALSignalConeSize_min", 0.0); + desc.add("EcalStripSumE_minClusEnergy", 0.1); + desc.add("EcalStripSumE_deltaEta", 0.03); + desc.add("TrackerIsolConeSizeFormula", "0.50"); + desc.add("LeadPFCand_minPt", 5.0); + desc.add("HCALSignalConeSize_min", 0.0); + desc.add("ECALSignalConeSize_max", 0.6); + desc.add("HCALSignalConeSizeFormula", "0.10"); + desc.add("putNeutralHadronsInP4", false); + desc.add("TrackLeadTrack_maxDZ", 1.0); + desc.add("ChargedHadrCand_IsolAnnulus_minNhits", 0); + desc.add("ECALIsolConeSize_min", 0.0); + desc.add("UseTrackLeadTrackDZconstraint", true); + desc.add("MaxEtInEllipse", 2.0); + desc.add("DataType", "AOD"); + desc.add("smearedPVsigmaZ", 0.005); + desc.add("MatchingConeSize_max", 0.6); + desc.add("HCALIsolConeSize_min", 0.0); + descriptions.add("pfRecoTauProducer", desc); +} + DEFINE_FWK_MODULE(PFRecoTauProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc index 2a4003f016153..c30f65fcfb890 100644 --- a/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFRecoTauTagInfoProducer.cc @@ -22,6 +22,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include + #include "CLHEP/Random/RandGauss.h" #include "Math/GenVector/VectorUtil.h" @@ -37,6 +40,7 @@ class PFRecoTauTagInfoProducer : public edm::global::EDProducer<> { explicit PFRecoTauTagInfoProducer(const edm::ParameterSet& iConfig); ~PFRecoTauTagInfoProducer() override; void produce(edm::StreamID, edm::Event&,const edm::EventSetup&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: std::unique_ptr PFRecoTauTagInfoAlgo_; edm::InputTag PFCandidateProducer_; @@ -106,4 +110,63 @@ else{ // OrphanHandle myPFTauTagInfoCollection=iEvent.put(std::move(resultExt)); iEvent.put(std::move(resultExt)); } + +void +PFRecoTauTagInfoProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + { + // pfRecoTauTagInfoProducerInsideOut + edm::ParameterSetDescription desc; + desc.add("tkminTrackerHitsn", 3); + desc.add("tkminPt", 0.5); + desc.add("tkmaxChi2", 100.0); + desc.add("ChargedHadrCand_AssociationCone", 1.0); + desc.add("ChargedHadrCand_tkminTrackerHitsn", 3); + desc.add("ChargedHadrCand_tkmaxChi2", 100.0); + desc.add("tkPVmaxDZ", 0.2); + desc.add("GammaCand_EcalclusMinEt", 1.0); + desc.add("tkminPixelHitsn", 0); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("PFCandidateProducer", edm::InputTag("particleFlow")); + desc.add("ChargedHadrCand_tkminPt", 0.5); + desc.add("ChargedHadrCand_tkmaxipt", 0.03); + desc.add("ChargedHadrCand_tkminPixelHitsn", 0); + desc.add("UsePVconstraint", true); + desc.add("NeutrHadrCand_HcalclusMinEt", 1.0); + desc.add("PFJetTracksAssociatorProducer", edm::InputTag("insideOutJetTracksAssociatorAtVertex")); + desc.add("smearedPVsigmaY", 0.0015); + desc.add("smearedPVsigmaX", 0.0015); + desc.add("smearedPVsigmaZ", 0.005); + desc.add("ChargedHadrCand_tkPVmaxDZ", 0.2); + desc.add("tkmaxipt", 0.03); + descriptions.add("pfRecoTauTagInfoProducerInsideOut", desc); + } + { + // pfRecoTauTagInfoProducer + edm::ParameterSetDescription desc; + desc.add("tkminTrackerHitsn", 3); + desc.add("tkminPt", 0.5); + desc.add("tkmaxChi2", 100.0); + desc.add("ChargedHadrCand_AssociationCone", 0.8); + desc.add("ChargedHadrCand_tkminTrackerHitsn", 3); + desc.add("ChargedHadrCand_tkmaxChi2", 100.0); + desc.add("tkPVmaxDZ", 0.2); + desc.add("GammaCand_EcalclusMinEt", 1.0); + desc.add("tkminPixelHitsn", 0); + desc.add("PVProducer", edm::InputTag("offlinePrimaryVertices")); + desc.add("PFCandidateProducer", edm::InputTag("particleFlow")); + desc.add("ChargedHadrCand_tkminPt", 0.5); + desc.add("ChargedHadrCand_tkmaxipt", 0.03); + desc.add("ChargedHadrCand_tkminPixelHitsn", 0); + desc.add("UsePVconstraint", true); + desc.add("NeutrHadrCand_HcalclusMinEt", 1.0); + desc.add("PFJetTracksAssociatorProducer", edm::InputTag("ak4PFJetTracksAssociatorAtVertex")); + desc.add("smearedPVsigmaY", 0.0015); + desc.add("smearedPVsigmaX", 0.0015); + desc.add("smearedPVsigmaZ", 0.005); + desc.add("ChargedHadrCand_tkPVmaxDZ", 0.2); + desc.add("tkmaxipt", 0.03); + descriptions.add("pfRecoTauTagInfoProducer", desc); + } +} + DEFINE_FWK_MODULE(PFRecoTauTagInfoProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauDecayModeCutMultiplexer.cc b/RecoTauTag/RecoTau/plugins/PFTauDecayModeCutMultiplexer.cc index 9dffc6f71aef1..db3f3860e4250 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauDecayModeCutMultiplexer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauDecayModeCutMultiplexer.cc @@ -25,6 +25,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include + using namespace reco; class PFTauDecayModeCutMultiplexer : public PFTauDiscriminationProducerBase { @@ -43,6 +46,7 @@ class PFTauDecayModeCutMultiplexer : public PFTauDiscriminationProducerBase { double discriminate(const PFTauRef& thePFTau) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: // PFTau discriminator continaing the decaymode index of the tau collection edm::InputTag pfTauDecayModeIndexSrc_; @@ -130,4 +134,26 @@ double PFTauDecayModeCutMultiplexer::discriminate(const PFTauRef& pfTau) const return 0.; } +void +PFTauDecayModeCutMultiplexer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfTauDecayModeCutMultiplexer + edm::ParameterSetDescription desc; + + desc.add("PFTauDecayModeSrc"); + desc.add("PFTauDiscriminantToMultiplex"); + + edm::ParameterSetDescription vpsd_computers; + vpsd_computers.add("computerName"); + vpsd_computers.add("cut"); + vpsd_computers.add >("decayModeIndices"); + + // name description defaults items + //desc.addVPSet("computers", vpsd_builders, builders_vector); + desc.addVPSet("computers", vpsd_computers); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("pfTauDecayModeCutMultiplexer", desc); +} + DEFINE_FWK_MODULE(PFTauDecayModeCutMultiplexer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauDiscriminatorLogicalAndProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauDiscriminatorLogicalAndProducer.cc index dbe23c8a1ac24..a81810d29c1a2 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauDiscriminatorLogicalAndProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauDiscriminatorLogicalAndProducer.cc @@ -1,4 +1,6 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" +#include +#include /* * class PFRecoTauDiscriminatioLogicalAndProducer @@ -21,6 +23,7 @@ class PFTauDiscriminatorLogicalAndProducer : public PFTauDiscriminationProducerB explicit PFTauDiscriminatorLogicalAndProducer(const edm::ParameterSet&); ~PFTauDiscriminatorLogicalAndProducer() override{}; double discriminate(const PFTauRef& pfTau) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: double passResult_; }; @@ -40,4 +43,33 @@ PFTauDiscriminatorLogicalAndProducer::discriminate(const PFTauRef& pfTau) const return passResult_; } +void +PFTauDiscriminatorLogicalAndProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // PFTauDiscriminatorLogicalAndProducer + edm::ParameterSetDescription desc; + + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut", 0.5); + psd1.add("Producer", edm::InputTag("pfRecoTauDiscriminationAgainstElectron")); + psd0.add("discr2", psd1); + } + { + edm::ParameterSetDescription psd1; + psd1.add("cut", 0.5); + psd1.add("Producer", edm::InputTag("pfRecoTauDiscriminationByIsolation")); + psd0.add("discr1", psd1); + } + desc.add("Prediscriminants", psd0); + } + + desc.add("PassValue", 1.0); + desc.add("FailValue", 0.0); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + descriptions.add("PFTauDiscriminatorLogicalAndProducer", desc); +} + DEFINE_FWK_MODULE(PFTauDiscriminatorLogicalAndProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc index 581d14382676c..58c095399dd73 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauPrimaryVertexProducer.cc @@ -19,6 +19,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" @@ -73,6 +76,8 @@ class PFTauPrimaryVertexProducer final : public edm::stream::EDProducer<> { ~PFTauPrimaryVertexProducer() override; void produce(edm::Event&,const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::InputTag PFTauTag_; edm::EDGetTokenT >PFTauToken_; @@ -124,8 +129,8 @@ PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(const edm::ParameterSet& else newCut->cut_ = pset.getParameter("selectionCut"); discriminators_.push_back(newCut); } - // Build a string cut if desired - if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); + // Build a string cut + cut_.reset(new StringCutObjectSelector(iConfig.getParameter( "cut" ))); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// produces > >(); produces("PFTauPrimaryVertices"); @@ -269,5 +274,79 @@ void PFTauPrimaryVertexProducer::produce(edm::Event& iEvent,const edm::EventSetu iEvent.put(std::move(VertexCollection_out),"PFTauPrimaryVertices"); iEvent.put(std::move(AVPFTauPV)); } - + +void +PFTauPrimaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // PFTauPrimaryVertexProducer + edm::ParameterSetDescription desc; + + { + edm::ParameterSetDescription vpsd1; + vpsd1.add("discriminator"); + vpsd1.add("selectionCut"); + desc.addVPSet("discriminators", vpsd1); + } + + { + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + desc.add("qualityCuts", pset_qualityCuts); + } + + desc.add("cut", "pt > 18.0 & abs(eta)<2.3"); + desc.add("Algorithm", 0); + desc.add("RemoveElectronTracks", false); + desc.add("RemoveMuonTracks", false); + desc.add("useBeamSpot", true); + desc.add("useSelectedTaus", false); + desc.add("beamSpot", edm::InputTag("offlineBeamSpot")); + desc.add("ElectronTag", edm::InputTag("MyElectrons")); + desc.add("PFTauTag", edm::InputTag("hpsPFTauProducer")); + desc.add("MuonTag", edm::InputTag("MyMuons")); + desc.add("PVTag", edm::InputTag("offlinePrimaryVertices")); + + descriptions.add("PFTauPrimaryVertexProducer", desc); +} + DEFINE_FWK_MODULE(PFTauPrimaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc index 134410e6ec463..57d216146a9a0 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauSecondaryVertexProducer.cc @@ -22,6 +22,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" @@ -54,6 +57,8 @@ class PFTauSecondaryVertexProducer : public edm::global::EDProducer<> { explicit PFTauSecondaryVertexProducer(const edm::ParameterSet& iConfig); ~PFTauSecondaryVertexProducer() override; void produce(edm::StreamID, edm::Event&,const edm::EventSetup&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: const edm::InputTag PFTauTag_; const edm::EDGetTokenT > PFTauToken_; @@ -126,4 +131,12 @@ void PFTauSecondaryVertexProducer::produce(edm::StreamID, edm::Event& iEvent,con iEvent.put(std::move(AVPFTauSV)); } +void +PFTauSecondaryVertexProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // PFTauSecondaryVertexProducer + edm::ParameterSetDescription desc; + desc.add("PFTauTag", edm::InputTag("hpsPFTauProducer")); + descriptions.add("PFTauSecondaryVertexProducer", desc); +} + DEFINE_FWK_MODULE(PFTauSecondaryVertexProducer); diff --git a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc index d8dd74a45c8bd..e02f78b438abe 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauTransverseImpactParameters.cc @@ -19,6 +19,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Exception.h" +#include +#include + #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" @@ -54,6 +57,8 @@ class PFTauTransverseImpactParameters : public edm::stream::EDProducer<> { explicit PFTauTransverseImpactParameters(const edm::ParameterSet& iConfig); ~PFTauTransverseImpactParameters() override; void produce(edm::Event&,const edm::EventSetup&) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::EDGetTokenT > PFTauToken_; edm::EDGetTokenT > > PFTauPVAToken_; @@ -162,4 +167,15 @@ void PFTauTransverseImpactParameters::produce(edm::Event& iEvent,const edm::Even iEvent.put(std::move(AVPFTauTIP)); } +void +PFTauTransverseImpactParameters::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // PFTauTransverseImpactParameters + edm::ParameterSetDescription desc; + desc.add("PFTauPVATag", edm::InputTag("PFTauPrimaryVertexProducer")); + desc.add("useFullCalculation", false); + desc.add("PFTauTag", edm::InputTag("hpsPFTauProducer")); + desc.add("PFTauSVATag", edm::InputTag("PFTauSecondaryVertexProducer")); + descriptions.add("PFTauTransverseImpactParameters", desc); +} + DEFINE_FWK_MODULE(PFTauTransverseImpactParameters); diff --git a/RecoTauTag/RecoTau/plugins/PFTauViewRefMerger.cc b/RecoTauTag/RecoTau/plugins/PFTauViewRefMerger.cc index 4699f3a1f8547..000bed36bd02f 100644 --- a/RecoTauTag/RecoTau/plugins/PFTauViewRefMerger.cc +++ b/RecoTauTag/RecoTau/plugins/PFTauViewRefMerger.cc @@ -11,6 +11,9 @@ #include "DataFormats/TauReco/interface/PFTauFwd.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" +#include +#include + #include "FWCore/Framework/interface/MakerMacros.h" #include "DataFormats/Candidate/interface/Candidate.h" #include "FWCore/Framework/interface/EDProducer.h" @@ -24,6 +27,7 @@ class PFTauViewRefMerger : public edm::EDProducer { src_(cfg.getParameter >("src")) { produces(); } + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: void produce(edm::Event & evt, const edm::EventSetup &) override { auto out = std::make_unique(); @@ -42,4 +46,15 @@ class PFTauViewRefMerger : public edm::EDProducer { std::vector src_; }; +void +PFTauViewRefMerger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfTauViewRefMerger + edm::ParameterSetDescription desc; + + desc.add>("src"); + + descriptions.add("pfTauViewRefMerger", desc); +} + + DEFINE_FWK_MODULE(PFTauViewRefMerger); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc index 26d1d68eae512..804420722520e 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauBuilderCombinatoricPlugin.cc @@ -82,8 +82,7 @@ RecoTauBuilderCombinatoricPlugin::RecoTauBuilderCombinatoricPlugin(const edm::Pa decayModesToBuild_.push_back(info); } - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } // define template specialization for cross-cleaning diff --git a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc index 0766874d6dd5b..36b76617a2b40 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauCleaner.cc @@ -24,6 +24,9 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" #include "RecoTauTag/RecoTau/interface/RecoTauCleaningTools.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" @@ -62,6 +65,8 @@ class RecoTauCleanerImpl : public edm::stream::EDProducer<> ~RecoTauCleanerImpl() override; void produce(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::InputTag tauSrc_; CleanerList cleaners_; @@ -87,22 +92,18 @@ RecoTauCleanerImpl::RecoTauCleanerImpl(const edm::ParameterSet& pset) const std::string& pluginType = cleanerPSet->getParameter("plugin"); // Build the plugin cleanerEntry->plugin_ = std::unique_ptr{RecoTauCleanerPluginFactory::get()->create(pluginType, *cleanerPSet, consumesCollector())}; - cleanerEntry->tolerance_ = ( cleanerPSet->exists("tolerance") ) ? - cleanerPSet->getParameter("tolerance") : 0.; + cleanerEntry->tolerance_ = cleanerPSet->getParameter("tolerance"); cleaners_.emplace_back(std::move(cleanerEntry)); } // Check if we want to apply a final output selection - if ( pset.exists("outputSelection") ) { - std::string selection = pset.getParameter("outputSelection"); - if ( !selection.empty() ) { - outputSelector_ = std::make_unique>(selection); - } + std::string selection = pset.getParameter("outputSelection"); + if ( !selection.empty() ) { + outputSelector_ = std::make_unique>(selection); } // Enable/disable debug output - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); // Build the predicate that ranks our taus. produces(); @@ -298,6 +299,115 @@ void RecoTauCleanerImpl::produce(edm::Event& evt, const edm::EventSetup& e typedef RecoTauCleanerImpl RecoTauCleaner; typedef RecoTauCleanerImpl RecoTauRefCleaner; +template <> +void +RecoTauCleanerImpl::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // RecoTauCleaner + edm::ParameterSetDescription desc; + desc.add("outputSelection", ""); + { + // this description is the validator for all PSets in the cleaners VPSet passed to the plugin from the python configuration + edm::ParameterSetDescription vps_description_for_cleaners; + // the common parameters for all cleaners + // no default value is provided -- the user has to provide the values for these parameters + vps_description_for_cleaners.add("plugin"); + vps_description_for_cleaners.add("tolerance", 0); + vps_description_for_cleaners.add("name"); + + // the following parameters are not common for all cleaners, they are needed for few PSets, therefore they are added as optional + // these optional parameters are used in the default cleaners vector + vps_description_for_cleaners.addOptional("passForCharge"); + vps_description_for_cleaners.addOptional("selectionFailValue"); + vps_description_for_cleaners.addOptional>("nprongs"); + vps_description_for_cleaners.addOptional("src"); + vps_description_for_cleaners.addOptional("minTrackPt"); + vps_description_for_cleaners.addOptional("selection"); + vps_description_for_cleaners.addOptional("selectionPassFunction"); + // more PSets for cleaners can be found in + // RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py + // however, at this moment (2018-11-09) they do not have any new optional parameters + + // the cleaner defaults, as in RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py + std::vector default_cleaners; + default_cleaners.reserve(7); + { + edm::ParameterSet cleaner_Charge; + cleaner_Charge.addParameter("name", "Charge"); + cleaner_Charge.addParameter("plugin", "RecoTauChargeCleanerPlugin"); + cleaner_Charge.addParameter("passForCharge", 1); + cleaner_Charge.addParameter("selectionFailValue", 0); + cleaner_Charge.addParameter>("nprongs", {1, 3,}); + cleaner_Charge.addParameter("tolerance", 0); + default_cleaners.push_back(cleaner_Charge); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "HPS_Select"); + temp2.addParameter("plugin", "RecoTauDiscriminantCleanerPlugin"); + temp2.addParameter("src", edm::InputTag("hpsSelectionDiscriminator")); + temp2.addParameter("tolerance", 0); + default_cleaners.push_back(temp2); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "killSoftTwoProngTaus"); + temp2.addParameter("plugin", "RecoTauSoftTwoProngTausCleanerPlugin"); + temp2.addParameter("minTrackPt", 5.0); + temp2.addParameter("tolerance", 0); + default_cleaners.push_back(temp2); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "ChargedHadronMultiplicity"); + temp2.addParameter("plugin", "RecoTauChargedHadronMultiplicityCleanerPlugin"); + temp2.addParameter("tolerance", 0); + default_cleaners.push_back(temp2); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "Pt"); + temp2.addParameter("plugin", "RecoTauStringCleanerPlugin"); + temp2.addParameter("selectionPassFunction", "-pt()"); + temp2.addParameter("selection", "leadPFCand().isNonnull()"); + temp2.addParameter("selectionFailValue", 1000.0); + temp2.addParameter("tolerance", 0.01); + default_cleaners.push_back(temp2); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "StripMultiplicity"); + temp2.addParameter("plugin", "RecoTauStringCleanerPlugin"); + temp2.addParameter("selectionPassFunction", "-signalPiZeroCandidates().size()"); + temp2.addParameter("selection", "leadPFCand().isNonnull()"); + temp2.addParameter("selectionFailValue", 1000.0); + temp2.addParameter("tolerance", 0); + default_cleaners.push_back(temp2); + } + { + edm::ParameterSet temp2; + temp2.addParameter("name", "CombinedIsolation"); + temp2.addParameter("plugin", "RecoTauStringCleanerPlugin"); + temp2.addParameter("selectionPassFunction", "isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()"); + temp2.addParameter("selection", "leadPFCand().isNonnull()"); + temp2.addParameter("selectionFailValue", 1000.0); + temp2.addParameter("tolerance", 0); + default_cleaners.push_back(temp2); + } + + desc.addVPSet("cleaners", vps_description_for_cleaners, default_cleaners); + } + + desc.add("verbosity", 0); + desc.add("src", edm::InputTag("combinatoricRecoTaus")); + descriptions.add("RecoTauCleaner", desc); +} + +template <> +void +RecoTauCleanerImpl::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +// there was no cfi file for this plugin +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauCleaner); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc b/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc index 3ed2c0b05fe54..627d447975cae 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDecayModeCutMultiplexer.cc @@ -1,6 +1,9 @@ #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + class RecoTauDecayModeCutMultiplexer : public PFTauDiscriminationProducerBase { public: explicit RecoTauDecayModeCutMultiplexer(const edm::ParameterSet& pset); @@ -9,6 +12,7 @@ class RecoTauDecayModeCutMultiplexer : public PFTauDiscriminationProducerBase { double discriminate(const reco::PFTauRef&) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: typedef std::pair IntPair; typedef std::map DecayModeCutMap; @@ -60,4 +64,26 @@ RecoTauDecayModeCutMultiplexer::discriminate(const reco::PFTauRef& tau) const { return disc_result > cutIter->second; } +void +RecoTauDecayModeCutMultiplexer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // recoTauDecayModeCutMultiplexer + edm::ParameterSetDescription desc; + + desc.add("toMultiplex"); + + edm::ParameterSetDescription vpsd_decayModes; + + vpsd_decayModes.add("nCharged"); + vpsd_decayModes.add("nPiZeros"); + vpsd_decayModes.add("cut"); + + // name description no defaults items + desc.addVPSet("decayModes", vpsd_decayModes); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("recoTauDecayModeCutMultiplexer", desc); +} + + DEFINE_FWK_MODULE(RecoTauDecayModeCutMultiplexer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantCutMultiplexer.cc b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantCutMultiplexer.cc index 8df7c762210d8..4d0791773405e 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantCutMultiplexer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantCutMultiplexer.cc @@ -21,6 +21,9 @@ #include "DataFormats/TauReco/interface/PFTau.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include +#include + #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTGraphPayload.h" #include "CondFormats/DataRecord/interface/PhysicsTGraphPayloadRcd.h" #include "CondFormats/PhysicsToolsObjects/interface/PhysicsTFormulaPayload.h" @@ -39,7 +42,9 @@ class RecoTauDiscriminantCutMultiplexer : public PFTauDiscriminationProducerBase ~RecoTauDiscriminantCutMultiplexer() override; double discriminate(const reco::PFTauRef&) const override; void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup) override; - + + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; @@ -145,19 +150,14 @@ RecoTauDiscriminantCutMultiplexer::RecoTauDiscriminantCutMultiplexer(const edm:: key_ = cfg.getParameter("key"); key_token = consumes(key_); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); - loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter("loadMVAfromDB") : false; + loadMVAfromDB_ = cfg.getParameter("loadMVAfromDB"); if ( !loadMVAfromDB_ ) { - if(cfg.exists("inputFileName")){ inputFileName_ = cfg.getParameter("inputFileName"); - }else throw cms::Exception("MVA input not defined") << "Requested to load tau MVA input from ROOT file but no file provided in cfg file"; } if(verbosity_) std::cout << moduleLabel_ << " loadMVA = " << loadMVAfromDB_ << std::endl; - if ( cfg.exists("mvaOutput_normalization") ) { - mvaOutputNormalizationName_ = cfg.getParameter("mvaOutput_normalization"); - } + mvaOutputNormalizationName_ = cfg.getParameter("mvaOutput_normalization"); // Setup our cut map typedef std::vector VPSet; @@ -181,6 +181,7 @@ RecoTauDiscriminantCutMultiplexer::RecoTauDiscriminantCutMultiplexer(const edm:: cuts_[category] = std::move(cut); } + verbosity_ = cfg.getParameter("verbosity"); if(verbosity_) std::cout << "constructed " << moduleLabel_ << std::endl; } @@ -279,4 +280,37 @@ RecoTauDiscriminantCutMultiplexer::discriminate(const reco::PFTauRef& tau) const return passesCuts; } +void +RecoTauDiscriminantCutMultiplexer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // recoTauDiscriminantCutMultiplexer + edm::ParameterSetDescription desc; + desc.add("toMultiplex", edm::InputTag("fixme")); + desc.add("verbosity", 0); + + { + edm::ParameterSet pset_mapping; + pset_mapping.addParameter("category",0); + pset_mapping.addParameter("cut",0.); + edm::ParameterSetDescription desc_mapping; + desc_mapping.add("category",0); + desc_mapping.addNode(edm::ParameterDescription("cut", true) xor + edm::ParameterDescription("cut", true)); + // it seems the parameter string "variable" exists only when "cut" is string + // see hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT in RecoTauTag/Configuration/python/HPSPFTaus_cff.py + desc_mapping.addOptional("variable")->setComment("the parameter is required when \"cut\" is string"); + // desc_mapping.add("cut",0.); + std::vector vpsd_mapping; + vpsd_mapping.push_back(pset_mapping); + desc.addVPSet("mapping",desc_mapping,vpsd_mapping); + } + + desc.add("inputFileName", edm::FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile")); + desc.add("loadMVAfromDB", true); + fillProducerDescriptions(desc); // inherited from the base + desc.add("mvaOutput_normalization", ""); + desc.add("key", edm::InputTag("fixme")); + descriptions.add("recoTauDiscriminantCutMultiplexerDefault", desc); +} + + DEFINE_FWK_MODULE(RecoTauDiscriminantCutMultiplexer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantFromDiscriminator.cc b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantFromDiscriminator.cc index c39ed44a4d93b..07cab300d3552 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantFromDiscriminator.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminantFromDiscriminator.cc @@ -31,26 +31,15 @@ class RecoTauDiscriminantFromDiscriminator : public RecoTauDiscriminantPlugin{ RecoTauDiscriminantFromDiscriminator::RecoTauDiscriminantFromDiscriminator( const edm::ParameterSet& pset):RecoTauDiscriminantPlugin(pset) { - takeAbs_ = pset.existsAs("takeAbs") ? - pset.getParameter("takeAbs") : false; - min_ = pset.existsAs("minValue") ? - pset.getParameter("minValue") : -1*std::numeric_limits::max(); - max_ = pset.existsAs("maxValue") ? - pset.getParameter("maxValue") : std::numeric_limits::max(); - if (pset.existsAs("discSrc")) { - discriminators_.push_back(std::make_pair( - pset.getParameter("discSrc"), - edm::Handle())); - } else { - // Get multiple discriminators. This supports the case when the MVAHelper - // class might be dealing with multiple tau collections (training) - std::vector discriminators = - pset.getParameter >("discSrc"); - for(auto const& tag : discriminators) { - discriminators_.push_back(std::make_pair( - tag, edm::Handle())); - } + takeAbs_ = pset.getParameter("takeAbs"); + min_ = pset.getParameter("minValue"); + max_ = pset.getParameter("maxValue"); + + std::vector discriminators = + pset.getParameter >("discSrc"); + for(auto const& tag : discriminators) { + discriminators_.push_back(std::make_pair(tag, edm::Handle())); } } diff --git a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc b/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc deleted file mode 100644 index e9779116dd38f..0000000000000 --- a/RecoTauTag/RecoTau/plugins/RecoTauDiscriminationByFlight.cc +++ /dev/null @@ -1,134 +0,0 @@ -#include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" -#include "DataFormats/VertexReco/interface/Vertex.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" - -#include "TrackingTools/TransientTrack/interface/TransientTrack.h" -#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" -#include "TrackingTools/Records/interface/TransientTrackRecord.h" -#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h" -#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" -#include "RecoBTag/SecondaryVertex/interface/SecondaryVertex.h" -#include "TrackingTools/IPTools/interface/IPTools.h" - -class PFRecoTauDiscriminationByFlight : public PFTauDiscriminationProducerBase { - public: - PFRecoTauDiscriminationByFlight(const edm::ParameterSet& pset); - ~PFRecoTauDiscriminationByFlight() override{} - void beginEvent(const edm::Event& evt, const edm::EventSetup& es) override; - double discriminate(const reco::PFTauRef&) const override; - private: - edm::InputTag vertexSource_; - edm::InputTag bsSource_; - edm::Handle vertices_; - edm::Handle beamspot_; - const TransientTrackBuilder* builder_; - double oneProngSig_; - double threeProngSig_; - bool refitPV_; -}; - -PFRecoTauDiscriminationByFlight::PFRecoTauDiscriminationByFlight( - const edm::ParameterSet& pset):PFTauDiscriminationProducerBase(pset) { - vertexSource_ = pset.getParameter("vertexSource"); - oneProngSig_ = pset.exists("oneProngSigCut") ? - pset.getParameter("oneProngSigCut") : -1.; - threeProngSig_ = pset.exists("threeProngSigCut") ? - pset.getParameter("threeProngSigCut") : -1.; - refitPV_ = pset.getParameter("refitPV"); - if (refitPV_) - bsSource_ = pset.getParameter("beamspot"); -} - -void PFRecoTauDiscriminationByFlight::beginEvent( - const edm::Event& evt, const edm::EventSetup& es) { - evt.getByLabel(vertexSource_, vertices_); - if (refitPV_) - evt.getByLabel(bsSource_, beamspot_); - edm::ESHandle transTrackBuilder; - es.get().get("TransientTrackBuilder",transTrackBuilder); - builder_ = transTrackBuilder.product(); -} - -double PFRecoTauDiscriminationByFlight::discriminate( - const reco::PFTauRef& tau) const { - - KalmanVertexFitter kvf(true); - const std::vector& signalTracks = - tau->signalPFChargedHadrCands(); - std::vector signalTransTracks; - std::vector signalTrackPtrs; - for(auto const& pftrack : signalTracks) { - if (pftrack->trackRef().isNonnull()) { - signalTransTracks.push_back( - builder_->build(pftrack->trackRef())); - signalTrackPtrs.push_back(pftrack->trackRef()); - } - } - - reco::Vertex pv = (*vertices_)[0]; - - if (refitPV_) { - std::vector pvTrackRefs; - for (reco::Vertex::trackRef_iterator pvTrack = pv.tracks_begin(); - pvTrack != pv.tracks_end(); ++pvTrack ) { - pvTrackRefs.push_back(pvTrack->castTo()); - } - // Get PV tracks not associated to the tau - std::sort(signalTrackPtrs.begin(), signalTrackPtrs.end()); - std::sort(pvTrackRefs.begin(), pvTrackRefs.end()); - std::vector uniquePVTracks; - uniquePVTracks.reserve(pvTrackRefs.size()); - std::set_difference(pvTrackRefs.begin(), pvTrackRefs.end(), - signalTrackPtrs.begin(), signalTrackPtrs.end(), - std::back_inserter(uniquePVTracks)); - // Check if we need to refit - if (uniquePVTracks.size() != pvTrackRefs.size()) { - std::vector pvTransTracks; - // Build all our unique transient tracks in the PV - for(auto const& track : pvTrackRefs) { - pvTransTracks.push_back(builder_->build(track)); - } - // Refit our PV - TransientVertex newPV = kvf.vertex(pvTransTracks, *beamspot_); - pv = newPV; - } - } - - // The tau direction, to determine the sign of the IP. - // In the case that it is a one prong, take the jet direction. - // This may give better result due to out-of-cone stuff. - GlobalVector direction = (tau->signalPFCands().size() == 1 ? - GlobalVector( - tau->jetRef()->px(), tau->jetRef()->py(), tau->jetRef()->pz()) : - GlobalVector(tau->px(), tau->py(), tau->pz())); - - // Now figure out of we are doing a SV fit or an IP significance - if (signalTransTracks.size() == 1) { - reco::TransientTrack track = signalTransTracks.front(); - std::pair ipsig = - IPTools::signedTransverseImpactParameter(track, direction, pv); - if (ipsig.first) - return ipsig.second.significance(); - else - return prediscriminantFailValue_; - } else if (signalTransTracks.size() == 3) { - // Fit the decay vertex of the three prong - TransientVertex sv = kvf.vertex(signalTransTracks); - // the true parameter indicates include PV errors - Measurement1D svDist = reco::SecondaryVertex::computeDist2d( - pv, sv, direction, true); - double significance = svDist.significance(); - // Make sure it is a sane value - if (significance > 40) - significance = 40; - if (significance < -20) - significance = -20; - return significance; - } else { - // Weird two prong or something - return prediscriminantFailValue_; - } -} - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(PFRecoTauDiscriminationByFlight); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc index 67e31689a4716..b17b03dc2bbe4 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauJetRegionProducer.cc @@ -26,6 +26,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include +#include + #include #include @@ -39,6 +42,8 @@ class RecoTauJetRegionProducer : public edm::stream::EDProducer<> void produce(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: std::string moduleLabel_; @@ -70,11 +75,10 @@ RecoTauJetRegionProducer::RecoTauJetRegionProducer(const edm::ParameterSet& cfg) double deltaR = cfg.getParameter("deltaR"); deltaR2_ = deltaR*deltaR; - minJetPt_ = ( cfg.exists("minJetPt") ) ? cfg.getParameter("minJetPt") : -1.0; - maxJetAbsEta_ = ( cfg.exists("maxJetAbsEta") ) ? cfg.getParameter("maxJetAbsEta") : 99.0; + minJetPt_ = cfg.getParameter("minJetPt"); + maxJetAbsEta_ = cfg.getParameter("maxJetAbsEta"); - verbosity_ = ( cfg.exists("verbosity") ) ? - cfg.getParameter("verbosity") : 0; + verbosity_ = cfg.getParameter("verbosity"); produces("jets"); produces(); @@ -108,10 +112,10 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e size_t nJets = jets.size(); // Get the association map matching jets to PFCandidates - // (needed for recinstruction of boosted taus) + // (needed for reconstruction of boosted taus) edm::Handle jetToPFCandMap; std::vector > fastJetToPFCandMap; - if ( pfCandAssocMapSrc_.label() != "" ) { + if ( !pfCandAssocMapSrc_.label().empty() ) { evt.getByToken(pfCandAssocMap_token, jetToPFCandMap); fastJetToPFCandMap.resize(nJets); for ( size_t ijet = 0; ijet < nJets; ++ijet ) { @@ -206,5 +210,19 @@ void RecoTauJetRegionProducer::produce(edm::Event& evt, const edm::EventSetup& e evt.put(std::move(matching)); } +void +RecoTauJetRegionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // RecoTauJetRegionProducer + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("ak4PFJets")); + desc.add("deltaR", 0.8); + desc.add("pfCandAssocMapSrc", edm::InputTag("")); + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("minJetPt", 14.0); + desc.add("pfCandSrc", edm::InputTag("particleFlow")); + descriptions.add("RecoTauJetRegionProducer", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauJetRegionProducer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauMVATransform.cc b/RecoTauTag/RecoTau/plugins/RecoTauMVATransform.cc index 6afc9c40f01c7..c8d3f93b06d15 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauMVATransform.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauMVATransform.cc @@ -20,6 +20,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include + #include "TGraph.h" namespace { @@ -49,6 +52,7 @@ class RecoTauMVATransform : public PFTauDiscriminationProducerBase { void beginEvent(const edm::Event&, const edm::EventSetup&) override; double discriminate(const reco::PFTauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: // Map a decay mode to a transformation typedef boost::ptr_map TransformMap; @@ -108,5 +112,31 @@ double RecoTauMVATransform::discriminate(const reco::PFTauRef& tau) const { return result; } +void +RecoTauMVATransform::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // recoTauMVATransform + edm::ParameterSetDescription desc; + + desc.add("toTransform"); + + edm::ParameterSetDescription vpsd_transforms; + vpsd_transforms.add("nCharged"); + vpsd_transforms.add("nPiZeros"); + + edm::ParameterSetDescription pset_transform; + pset_transform.add("min"); + pset_transform.add("max"); + pset_transform.add>("transform"); + vpsd_transforms.add("transform", pset_transform); + + // name description no defaults items + desc.addVPSet("transforms", vpsd_transforms); + + fillProducerDescriptions(desc); // inherited from the base + + descriptions.add("recoTauMVATransform", desc); +} + + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauMVATransform); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc index 3f9723454df19..65d49a7e81d39 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroProducer.cc @@ -23,6 +23,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include +#include #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h" #include "RecoTauTag/RecoTau/interface/RecoTauCleaningTools.h" @@ -47,6 +49,8 @@ class RecoTauPiZeroProducer : public edm::stream::EDProducer<> { void print(const std::vector& piZeros, std::ostream& out); + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: typedef boost::ptr_vector builderList; typedef boost::ptr_vector rankerList; @@ -77,8 +81,8 @@ class RecoTauPiZeroProducer : public edm::stream::EDProducer<> { RecoTauPiZeroProducer::RecoTauPiZeroProducer(const edm::ParameterSet& pset) { cand_token = consumes( pset.getParameter("jetSrc")); - minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter("minJetPt") : -1.0; - maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter("maxJetAbsEta") : 99.0; + minJetPt_ = pset.getParameter("minJetPt"); + maxJetAbsEta_ = pset.getParameter("maxJetAbsEta"); typedef std::vector VPSet; // Get the mass hypothesis for the pizeros @@ -110,17 +114,14 @@ RecoTauPiZeroProducer::RecoTauPiZeroProducer(const edm::ParameterSet& pset) // Build the sorting predicate predicate_ = std::auto_ptr(new PiZeroPredicate(rankers_)); - // Check if we want to apply a final output selection - if (pset.exists("outputSelection")) { - std::string selection = pset.getParameter("outputSelection"); - if (!selection.empty()) { - outputSelector_.reset( - new StringCutObjectSelector(selection)); - } + // now all producers apply a final output selection + std::string selection = pset.getParameter("outputSelection"); + if (!selection.empty()) { + outputSelector_.reset( + new StringCutObjectSelector(selection)); } - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); produces(); } @@ -250,5 +251,261 @@ void RecoTauPiZeroProducer::print( } } +void +RecoTauPiZeroProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // common parameter descriptions + edm::ParameterSetDescription desc_ranking; + desc_ranking.add("selectionPassFunction","Func"); + desc_ranking.add("selectionFailValue",1000); + desc_ranking.add("selection","Sel"); + desc_ranking.add("name","name"); + desc_ranking.add("plugin","plugin"); + edm::ParameterSet pset_ranking; + pset_ranking.addParameter("selectionPassFunction",""); + pset_ranking.addParameter("selectionFailValue",1000); + pset_ranking.addParameter("selection",""); + pset_ranking.addParameter("name",""); + pset_ranking.addParameter("plugin",""); + std::vector vpsd_ranking; + vpsd_ranking.push_back(pset_ranking); + + edm::ParameterSetDescription desc_signalQualityCuts; + desc_signalQualityCuts.add("maxDeltaZ", 0.4); + desc_signalQualityCuts.add("minTrackPt", 0.5); + desc_signalQualityCuts.add("minTrackVertexWeight", -1.0); + desc_signalQualityCuts.add("maxTrackChi2", 100.0); + desc_signalQualityCuts.add("minTrackPixelHits", 0); + desc_signalQualityCuts.add("minGammaEt", 1.0); + desc_signalQualityCuts.add("minTrackHits", 3); + desc_signalQualityCuts.addOptional("minNeutralHadronEt"); + desc_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + desc_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription desc_vxAssocQualityCuts; + desc_vxAssocQualityCuts.add("minTrackPt", 0.5); + desc_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + desc_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + desc_vxAssocQualityCuts.add("minTrackPixelHits", 0); + desc_vxAssocQualityCuts.add("minGammaEt", 1.0); + desc_vxAssocQualityCuts.add("minTrackHits", 3); + desc_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + desc_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription desc_isolationQualityCuts; + desc_isolationQualityCuts.add("maxDeltaZ", 0.2); + desc_isolationQualityCuts.add("minTrackPt", 1.0); + desc_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + desc_isolationQualityCuts.add("maxTrackChi2", 100.0); + desc_isolationQualityCuts.add("minTrackPixelHits", 0); + desc_isolationQualityCuts.add("minGammaEt", 1.5); + desc_isolationQualityCuts.add("minTrackHits", 8); + desc_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + desc_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription desc_qualityCuts; + desc_qualityCuts.add("signalQualityCuts", desc_signalQualityCuts); + desc_qualityCuts.add("vxAssocQualityCuts", desc_vxAssocQualityCuts); + desc_qualityCuts.add("isolationQualityCuts", desc_isolationQualityCuts); + desc_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + desc_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + desc_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + desc_qualityCuts.add("vertexTrackFiltering", false); + desc_qualityCuts.add("recoverLeadingTrk", false); + + edm::ParameterSet pset_builders; + //pset_builders.addParameter("qualityCuts"); + pset_builders.addParameter("name",""); + pset_builders.addParameter("plugin",""); + pset_builders.addParameter("verbosity",0); + + { + // ak4PFJetsLegacyTaNCPiZeros + edm::ParameterSetDescription desc; + desc.add("massHypothesis", 0.136); + desc.addVPSet("ranking", desc_ranking, vpsd_ranking); + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "pt > 1.5"); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + + { + edm::ParameterSetDescription desc_builders; + desc_builders.setAllowAnything(); + desc_builders.add("qualityCuts", desc_qualityCuts); + desc_builders.add("name", "1"); + desc_builders.add("plugin", "RecoTauPiZeroTrivialPlugin"); + desc_builders.add("verbosity", 0); + + desc_builders.addOptional("makeCombinatoricStrips"); + desc_builders.addOptional("maxStripBuildIterations"); + desc_builders.addOptional("minGammaEtStripAdd"); + desc_builders.addOptional("minGammaEtStripSeed"); + desc_builders.addOptional("minStripEt"); + desc_builders.addOptional>("stripCandidatesParticleIds"); + desc_builders.addOptional("updateStripAfterEachDaughter"); + desc_builders.addOptional("applyElecTrackQcuts"); + + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + desc.addVPSet("builders", desc_builders, vpsd_builders); + } + + descriptions.add("ak4PFJetsLegacyTaNCPiZerosDefault", desc); + } + + { + // ak4PFJetsRecoTauGreedyPiZeros + edm::ParameterSetDescription desc; + desc.add("massHypothesis", 0.136); + desc.addVPSet("ranking", desc_ranking, vpsd_ranking); + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "pt > 1.5"); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + { + edm::ParameterSetDescription desc_builders; + desc_builders.setAllowAnything(); + desc_builders.add("qualityCuts", desc_qualityCuts); + desc_builders.add("maxInputStrips", 5); + desc_builders.add("name", "cs"); + desc_builders.add("plugin", "RecoTauPiZeroStripPlugin"); + desc_builders.add("stripMassWhenCombining", 0.0); + desc_builders.add("stripPhiAssociationDistance", 0.2); + desc_builders.add("stripEtaAssociationDistance", 0.05); + desc_builders.add("verbosity", 0); + + desc_builders.addOptional("makeCombinatoricStrips"); + desc_builders.addOptional("maxStripBuildIterations"); + desc_builders.addOptional("minGammaEtStripAdd"); + desc_builders.addOptional("minGammaEtStripSeed"); + desc_builders.addOptional("minStripEt"); + desc_builders.addOptional>("stripCandidatesParticleIds"); + desc_builders.addOptional("updateStripAfterEachDaughter"); + desc_builders.addOptional("applyElecTrackQcuts"); + + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + desc.addVPSet("builders", desc_builders, vpsd_builders); + } + descriptions.add("ak4PFJetsRecoTauGreedyPiZerosDefault", desc); + } + + { + // ak4PFJetsRecoTauPiZeros + edm::ParameterSetDescription desc; + desc.add("massHypothesis", 0.136); + desc.addVPSet("ranking", desc_ranking, vpsd_ranking); + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "pt > 1.5"); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + { + edm::ParameterSetDescription desc_builders; + desc_builders.setAllowAnything(); + desc_builders.add("qualityCuts", desc_qualityCuts); + desc_builders.add("name", "2"); + desc_builders.add("plugin", "RecoTauPiZeroCombinatoricPlugin"); + desc_builders.add("maxMass", -1.0); + desc_builders.add("minMass", 0.0); + desc_builders.add("choose", 2); + desc_builders.addOptional("maxInputGammas"); + desc_builders.add("verbosity", 0); + + desc_builders.addOptional("makeCombinatoricStrips"); + desc_builders.addOptional("maxStripBuildIterations"); + desc_builders.addOptional("minGammaEtStripAdd"); + desc_builders.addOptional("minGammaEtStripSeed"); + desc_builders.addOptional("minStripEt"); + desc_builders.addOptional>("stripCandidatesParticleIds"); + desc_builders.addOptional("updateStripAfterEachDaughter"); + desc_builders.addOptional("applyElecTrackQcuts"); + { + edm::ParameterSetDescription psd0; + psd0.addOptional("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.addOptional("par1", 0.707716); + psd0.addOptional("par0", 0.352476); + desc_builders.addOptional("stripPhiAssociationDistanceFunc", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.addOptional("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.addOptional("par1", 0.658701); + psd0.addOptional("par0", 0.197077); + desc_builders.addOptional("stripEtaAssociationDistanceFunc", psd0); + } + + // vpsd_builders.addOptional("stripPhiAssociationDistanceFunc"); + // vpsd_builders.addOptional("stripEtaAssociationDistanceFunc"); + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + desc.addVPSet("builders", desc_builders, vpsd_builders); + } + + descriptions.add("ak4PFJetsRecoTauPiZerosDefault", desc); + } + + { + // ak4PFJetsLegacyHPSPiZeros + edm::ParameterSetDescription desc; + desc.add("massHypothesis", 0.136); + desc.addVPSet("ranking", desc_ranking, vpsd_ranking); + desc.add("verbosity", 0); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "pt > 0"); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + edm::ParameterSetDescription desc_builders; + desc_builders.setAllowAnything(); + { + // both of the following uncommented version need to be accepted. + { + edm::ParameterSetDescription psd0; + psd0.add("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.add("par1", 0.707716); + psd0.add("par0", 0.352476); + desc_builders.addOptional("stripPhiAssociationDistanceFunc", psd0); + } + { + edm::ParameterSetDescription psd0; + psd0.add("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"); + psd0.add("par1", 0.658701); + psd0.add("par0", 0.197077); + desc_builders.addOptional("stripEtaAssociationDistanceFunc", psd0); + } + desc_builders.addOptional("stripEtaAssociationDistance", 0.05); + desc_builders.addOptional("stripPhiAssociationDistance", 0.2); + + desc_builders.add("qualityCuts", desc_qualityCuts); + + desc_builders.add("name"); + desc_builders.add("plugin"); + desc_builders.add("verbosity", 0); + + desc_builders.addOptional("makeCombinatoricStrips"); + desc_builders.addOptional("maxStripBuildIterations"); + desc_builders.addOptional("minGammaEtStripAdd"); + desc_builders.addOptional("minGammaEtStripSeed"); + desc_builders.addOptional("minStripEt"); + desc_builders.addOptional>("stripCandidatesParticleIds"); + desc_builders.addOptional("updateStripAfterEachDaughter"); + desc_builders.addOptional("applyElecTrackQcuts"); + + std::vector vpsd_builders; + vpsd_builders.push_back(pset_builders); + desc.addVPSet("builders", desc_builders, vpsd_builders); + } + + descriptions.add("ak4PFJetsLegacyHPSPiZerosDefault", desc); + descriptions.add("ak4PFJetsLegacyHPSPiZerosBoostedDefault", desc); // this one is generated in configs with a strange procedure + descriptions.add("pfJetsLegacyHPSPiZerosDefault", desc); + // RecoTauTag/Configuration/python/boostedHPSPFTaus_cfi.py + // process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted", addToTask = True) + } + +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauPiZeroProducer); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc index 7d9c4965ba709..6a01f7bab70bd 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin2.cc @@ -131,8 +131,7 @@ RecoTauPiZeroStripPlugin2::RecoTauPiZeroStripPlugin2(const edm::ParameterSet& ps combinatoricStripMassHypo_ = pset.getParameter("stripMassWhenCombining"); } - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } RecoTauPiZeroStripPlugin2::~RecoTauPiZeroStripPlugin2() diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc index 91a92bcd0a360..3f93130d60db9 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroStripPlugin3.cc @@ -141,9 +141,9 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps qcuts_.reset(new RecoTauQualityCuts(qcuts_pset)); inputPdgIds_ = pset.getParameter >("stripCandidatesParticleIds"); - const edm::ParameterSet& stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistance"); + const edm::ParameterSet& stripSize_eta_pset = pset.getParameterSet("stripEtaAssociationDistanceFunc"); etaAssociationDistance_ = makeFunction("etaAssociationDistance", stripSize_eta_pset); - const edm::ParameterSet& stripSize_phi_pset = pset.getParameterSet("stripPhiAssociationDistance"); + const edm::ParameterSet& stripSize_phi_pset = pset.getParameterSet("stripPhiAssociationDistanceFunc"); phiAssociationDistance_ = makeFunction("phiAssociationDistance", stripSize_phi_pset); updateStripAfterEachDaughter_ = pset.getParameter("updateStripAfterEachDaughter"); @@ -155,8 +155,7 @@ RecoTauPiZeroStripPlugin3::RecoTauPiZeroStripPlugin3(const edm::ParameterSet& ps combinatoricStripMassHypo_ = pset.getParameter("stripMassWhenCombining"); } - verbosity_ = ( pset.exists("verbosity") ) ? - pset.getParameter("verbosity") : 0; + verbosity_ = pset.getParameter("verbosity"); } RecoTauPiZeroStripPlugin3::~RecoTauPiZeroStripPlugin3() { diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroUnembedder.cc b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroUnembedder.cc index c0ec119921b47..508615ca3a9a3 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPiZeroUnembedder.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPiZeroUnembedder.cc @@ -16,6 +16,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/stream/EDProducer.h" +#include +#include + #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" #include "DataFormats/TauReco/interface/PFTau.h" @@ -28,6 +31,8 @@ class RecoTauPiZeroUnembedder : public edm::stream::EDProducer<> { RecoTauPiZeroUnembedder(const edm::ParameterSet& pset); ~RecoTauPiZeroUnembedder() override{} void produce(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::InputTag src_; edm::EDGetTokenT token; @@ -91,5 +96,13 @@ void RecoTauPiZeroUnembedder::produce(edm::Event& evt, const edm::EventSetup& es evt.put(std::move(tausOut)); } +void +RecoTauPiZeroUnembedder::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // RecoTauPiZeroUnembedder + edm::ParameterSetDescription desc; + desc.add("src", edm::InputTag("hpsPFTauProducerSansRefs")); + descriptions.add("RecoTauPiZeroUnembedder", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauPiZeroUnembedder); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauPileUpVertexSelector.cc b/RecoTauTag/RecoTau/plugins/RecoTauPileUpVertexSelector.cc index 45dbc8f5d8e77..b68d2630e3210 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauPileUpVertexSelector.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauPileUpVertexSelector.cc @@ -13,6 +13,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include +#include + #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" @@ -23,6 +26,7 @@ class RecoTauPileUpVertexSelector : public edm::stream::EDFilter<> { explicit RecoTauPileUpVertexSelector(const edm::ParameterSet &pset); ~RecoTauPileUpVertexSelector() override {} bool filter(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); private: edm::InputTag src_; double minPt_; @@ -35,7 +39,7 @@ RecoTauPileUpVertexSelector::RecoTauPileUpVertexSelector( pset.getParameter("minTrackSumPt")) { src_ = pset.getParameter("src"); token = consumes(src_); - filter_ = pset.exists("filter") ? pset.getParameter("filter") : false; + filter_ = pset.getParameter("filter"); produces(); } @@ -69,5 +73,17 @@ bool RecoTauPileUpVertexSelector::filter( return nPUVtx; } +void +RecoTauPileUpVertexSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // recoTauPileUpVertexSelector + edm::ParameterSetDescription desc; + + desc.add("minTrackSumPt"); + desc.add("src"); + desc.add("filter"); + + descriptions.add("recoTauPileUpVertexSelector", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauPileUpVertexSelector); diff --git a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc index 73882d86e21cf..46acd131360b3 100644 --- a/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc +++ b/RecoTauTag/RecoTau/plugins/RecoTauProducer.cc @@ -27,6 +27,8 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include +#include #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" @@ -53,6 +55,8 @@ class RecoTauProducer : public edm::stream::EDProducer<> ~RecoTauProducer() override {} void produce(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::InputTag jetSrc_; edm::InputTag jetRegionSrc_; @@ -84,8 +88,8 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) chargedHadronSrc_ = pset.getParameter("chargedHadronSrc"); piZeroSrc_ = pset.getParameter("piZeroSrc"); - minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter("minJetPt") : -1.0; - maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter("maxJetAbsEta") : 99.0; + minJetPt_ = pset.getParameter("minJetPt"); + maxJetAbsEta_ = pset.getParameter("maxJetAbsEta"); //consumes definition jet_token=consumes(jetSrc_); jetRegion_token = consumes >(jetRegionSrc_); @@ -113,11 +117,9 @@ RecoTauProducer::RecoTauProducer(const edm::ParameterSet& pset) } // Check if we want to apply a final output selection - if ( pset.exists("outputSelection") ) { - std::string selection = pset.getParameter("outputSelection"); - if ( !selection.empty() ) { - outputSelector_.reset(new StringCutObjectSelector(selection)); - } + std::string selection = pset.getParameter("outputSelection"); + if ( !selection.empty() ) { + outputSelector_.reset(new StringCutObjectSelector(selection)); } buildNullTaus_ = pset.getParameter("buildNullTaus"); @@ -238,5 +240,139 @@ void RecoTauProducer::produce(edm::Event& evt, const edm::EventSetup& es) evt.put(std::move(output)); } +void +RecoTauProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // combinatoricRecoTaus + edm::ParameterSetDescription desc; + desc.add("piZeroSrc", edm::InputTag("ak4PFJetsRecoTauPiZeros")); + + edm::ParameterSetDescription pset_signalQualityCuts; + pset_signalQualityCuts.add("maxDeltaZ", 0.4); + pset_signalQualityCuts.add("minTrackPt", 0.5); + pset_signalQualityCuts.add("minTrackVertexWeight", -1.0); + pset_signalQualityCuts.add("maxTrackChi2", 100.0); + pset_signalQualityCuts.add("minTrackPixelHits", 0); + pset_signalQualityCuts.add("minGammaEt", 1.0); + pset_signalQualityCuts.add("minTrackHits", 3); + pset_signalQualityCuts.add("minNeutralHadronEt", 30.0); + pset_signalQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_signalQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_vxAssocQualityCuts; + pset_vxAssocQualityCuts.add("minTrackPt", 0.5); + pset_vxAssocQualityCuts.add("minTrackVertexWeight", -1.0); + pset_vxAssocQualityCuts.add("maxTrackChi2", 100.0); + pset_vxAssocQualityCuts.add("minTrackPixelHits", 0); + pset_vxAssocQualityCuts.add("minGammaEt", 1.0); + pset_vxAssocQualityCuts.add("minTrackHits", 3); + pset_vxAssocQualityCuts.add("maxTransverseImpactParameter", 0.1); + pset_vxAssocQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_isolationQualityCuts; + pset_isolationQualityCuts.add("maxDeltaZ", 0.2); + pset_isolationQualityCuts.add("minTrackPt", 1.0); + pset_isolationQualityCuts.add("minTrackVertexWeight", -1.0); + pset_isolationQualityCuts.add("maxTrackChi2", 100.0); + pset_isolationQualityCuts.add("minTrackPixelHits", 0); + pset_isolationQualityCuts.add("minGammaEt", 1.5); + pset_isolationQualityCuts.add("minTrackHits", 8); + pset_isolationQualityCuts.add("maxTransverseImpactParameter", 0.03); + pset_isolationQualityCuts.addOptional("useTracksInsteadOfPFHadrons"); + + edm::ParameterSetDescription pset_qualityCuts; + pset_qualityCuts.add("signalQualityCuts", pset_signalQualityCuts); + pset_qualityCuts.add("vxAssocQualityCuts", pset_vxAssocQualityCuts); + pset_qualityCuts.add("isolationQualityCuts", pset_isolationQualityCuts); + pset_qualityCuts.add("leadingTrkOrPFCandOption", "leadPFCand"); + pset_qualityCuts.add("pvFindingAlgo", "closestInDeltaZ"); + pset_qualityCuts.add("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices")); + pset_qualityCuts.add("vertexTrackFiltering", false); + pset_qualityCuts.add("recoverLeadingTrk", false); + + { + edm::ParameterSetDescription vpsd_modifiers; + vpsd_modifiers.add("name"); + vpsd_modifiers.add("plugin"); + vpsd_modifiers.add("verbosity", 0); + + vpsd_modifiers.add("qualityCuts", pset_qualityCuts); + vpsd_modifiers.addOptional("ElectronPreIDProducer"); + vpsd_modifiers.addOptional("DataType"); + vpsd_modifiers.addOptional("maximumForElectrionPreIDOutput"); + vpsd_modifiers.addOptional("ElecPreIDLeadTkMatch_maxDR"); + vpsd_modifiers.addOptional("EcalStripSumE_minClusEnergy"); + vpsd_modifiers.addOptional("EcalStripSumE_deltaPhiOverQ_minValue"); + vpsd_modifiers.addOptional("EcalStripSumE_deltaPhiOverQ_maxValue"); + vpsd_modifiers.addOptional("EcalStripSumE_deltaEta"); + vpsd_modifiers.addOptional("dRaddNeutralHadron"); + vpsd_modifiers.addOptional("minGammaEt"); + vpsd_modifiers.addOptional("dRaddPhoton"); + vpsd_modifiers.addOptional("minNeutralHadronEt"); + vpsd_modifiers.addOptional("pfTauTagInfoSrc"); + + desc.addVPSet("modifiers", vpsd_modifiers); + } + + desc.add("jetRegionSrc", edm::InputTag("recoTauAK4PFJets08Region")); + desc.add("maxJetAbsEta", 2.5); + desc.add("outputSelection", "leadPFChargedHadrCand().isNonnull()"); + desc.add("chargedHadronSrc", edm::InputTag("ak4PFJetsRecoTauChargedHadrons")); + desc.add("minJetPt", 14.0); + desc.add("jetSrc", edm::InputTag("ak4PFJets")); + + { + edm::ParameterSetDescription desc_builders; + desc_builders.add("name"); + desc_builders.add("plugin"); + desc_builders.add("verbosity", 0); + + desc_builders.add("qualityCuts", pset_qualityCuts); + { + edm::ParameterSetDescription desc_decayModes; + desc_decayModes.add("nPiZeros", 0); + desc_decayModes.add("maxPiZeros", 0); + desc_decayModes.add("nCharged", 1); + desc_decayModes.add("maxTracks", 6); + desc_builders.addVPSetOptional("decayModes", desc_decayModes); + } + desc_builders.add("minAbsPhotonSumPt_insideSignalCone", 2.5); + desc_builders.add("minRelPhotonSumPt_insideSignalCone", 0.1); + desc_builders.add("pfCandSrc", edm::InputTag("particleFlow")); + + desc_builders.addOptional("signalConeSize"); + desc_builders.addOptional("isolationConeSize"); + desc_builders.addOptional("minAbsPhotonSumPt_outsideSignalCone"); + desc_builders.addOptional("minRelPhotonSumPt_outsideSignalCone"); + desc_builders.addOptional("isoConeChargedHadrons"); + desc_builders.addOptional("isoConeNeutralHadrons"); + desc_builders.addOptional("isoConePiZeros"); + desc_builders.addOptional("leadObjectPt"); + desc_builders.addOptional("matchingCone"); + desc_builders.addOptional("maxSignalConeChargedHadrons"); + desc_builders.addOptional("signalConeChargedHadrons"); + desc_builders.addOptional("signalConeNeutralHadrons"); + desc_builders.addOptional("signalConePiZeros"); + desc_builders.addOptional("usePFLeptons"); + + std::vector vpset_default; + { + edm::ParameterSet pset_default_builders; + pset_default_builders.addParameter("name",""); + pset_default_builders.addParameter("plugin",""); + pset_default_builders.addParameter("verbosity",0); + pset_default_builders.addParameter("minAbsPhotonSumPt_insideSignalCone", 2.5); + pset_default_builders.addParameter("minRelPhotonSumPt_insideSignalCone", 0.1); + pset_default_builders.addParameter("pfCandSrc", edm::InputTag("particleFlow")); + vpset_default.push_back(pset_default_builders); + } + desc.addVPSet("builders", desc_builders, vpset_default); + + } + + desc.add("buildNullTaus", false); + desc.add("verbosity", 0); + descriptions.add("combinatoricRecoTaus", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(RecoTauProducer); diff --git a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc index 1a4cc1e2eaa7e..dbbe61fc643bb 100644 --- a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc +++ b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstCaloMuon.cc @@ -11,6 +11,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" @@ -103,6 +106,8 @@ class TauDiscriminationAgainstCaloMuon final : public TauDiscriminationProducerB double discriminate(const TauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: edm::InputTag srcEcalRecHitsBarrel_; edm::Handle ebRecHits_; @@ -307,5 +312,43 @@ double TauDiscriminationAgainstCaloMuon::discriminate typedef TauDiscriminationAgainstCaloMuon PFRecoTauDiscriminationAgainstCaloMuon; typedef TauDiscriminationAgainstCaloMuon CaloRecoTauDiscriminationAgainstCaloMuon; +// accordingly method for specific class +template<> +void +TauDiscriminationAgainstCaloMuon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // pfRecoTauDiscriminationAgainstCaloMuon + edm::ParameterSetDescription desc; + desc.add("srcHcalRecHits", edm::InputTag("hbhereco")); + desc.add("minLeadTrackPt", 15.0); + desc.add("maxEnToTrackRatio", 0.25); + desc.add("srcVertex", edm::InputTag("offlinePrimaryVertices")); + desc.add("PFTauProducer", edm::InputTag("pfRecoTauProducer")); + desc.add("srcEcalRecHitsBarrel", edm::InputTag("ecalRecHit","EcalRecHitsEB")); + desc.add("dRhcal", 25.0); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("maxEnHcal", 8.0); + desc.add("dRecal", 15.0); + desc.add("srcEcalRecHitsEndcap", edm::InputTag("ecalRecHit","EcalRecHitsEE")); + desc.add("minLeadTrackPtFraction", 0.8); + desc.add("maxEnEcal", 3.0); + descriptions.add("pfRecoTauDiscriminationAgainstCaloMuon", desc); +} + +template<> +void +TauDiscriminationAgainstCaloMuon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // there was no cfi file for this plugin +} + DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstCaloMuon); DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstCaloMuon); diff --git a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstMuon.cc b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstMuon.cc index c0f71371a926e..0a7bc021a6ba4 100644 --- a/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstMuon.cc +++ b/RecoTauTag/RecoTau/plugins/TauDiscriminationAgainstMuon.cc @@ -11,6 +11,9 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" +#include +#include + #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/MuonReco/interface/MuonSelectors.h" @@ -37,6 +40,8 @@ class TauDiscriminationAgainstMuon final : public TauDiscriminationProducerBase< double discriminate(const TauRef&) const override; + static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + private: bool evaluateMuonVeto(const reco::Muon&) const; @@ -56,9 +61,8 @@ template TauDiscriminationAgainstMuon::TauDiscriminationAgainstMuon(const edm::ParameterSet& cfg) : TauDiscriminationProducerBase(cfg) { - //if ( cfg.exists("muonSource") ) muonSource_ = cfg.getParameter("muonSource"); muonSource_ = cfg.getParameter("muonSource"); - dRmatch_ = ( cfg.exists("dRmatch") ) ? cfg.getParameter("dRmatch") : 0.5; + dRmatch_ = cfg.getParameter("dRmatch"); std::string discriminatorOption_string = cfg.getParameter("discriminatorOption"); if ( discriminatorOption_string == "noSegMatch" ) discriminatorOption_ = kNoSegMatch; @@ -122,6 +126,32 @@ double TauDiscriminationAgainstMuon::discriminate(con } } +template +void TauDiscriminationAgainstMuon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +//CaloRecoTauDiscriminationAgainstMuon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // caloRecoTauDiscriminationAgainstMuon + edm::ParameterSetDescription desc; + desc.add("CaloTauProducer", edm::InputTag("caloRecoTauProducer")); + desc.add("muonSource", edm::InputTag("muons")); + desc.add("muonCompCut", 0.0); + desc.add("segmCompCoefficient", 0.5); + desc.add("dRmatch", 0.5); + { + edm::ParameterSetDescription psd0; + psd0.add("BooleanOperator", "and"); + { + edm::ParameterSetDescription psd1; + psd1.add("cut"); + psd1.add("Producer"); + psd0.addOptional("leadTrack", psd1); + } + desc.add("Prediscriminants", psd0); + } + desc.add("discriminatorOption", "noSegMatch"); + desc.add("caloCompCoefficient", 0.5); + descriptions.add("caloRecoTauDiscriminationAgainstMuon", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" //typedef TauDiscriminationAgainstMuon PFRecoTauDiscriminationAgainstMuon; diff --git a/RecoTauTag/RecoTau/python/HLTPFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/HLTPFRecoTauDiscriminationByIsolation_cfi.py index f3b0e8ef74511..74fcf27b85d75 100644 --- a/RecoTauTag/RecoTau/python/HLTPFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/HLTPFRecoTauDiscriminationByIsolation_cfi.py @@ -45,8 +45,8 @@ # By default, the pt threshold for tracks used to compute the DeltaBeta # correction is taken as the gamma Et threshold from the isolation quality # cuts. - # Uncommenting the parameter below allows this threshold to be overridden. - deltaBetaPUTrackPtCutOverride = cms.double(0.5), + deltaBetaPUTrackPtCutOverride = cms.bool(True), # Set the boolean = True to override. + deltaBetaPUTrackPtCutOverride_val = cms.double(0.5), # Set the value for new value. # Rho corrections applyRhoCorrection = cms.bool(False), diff --git a/RecoTauTag/RecoTau/python/PATTauDiscriminantCutMultiplexer_cfi.py b/RecoTauTag/RecoTau/python/PATTauDiscriminantCutMultiplexer_cfi.py index ebbc8afcb3119..a38100a00ebe3 100644 --- a/RecoTauTag/RecoTau/python/PATTauDiscriminantCutMultiplexer_cfi.py +++ b/RecoTauTag/RecoTau/python/PATTauDiscriminantCutMultiplexer_cfi.py @@ -23,6 +23,11 @@ ), key = cms.InputTag("fixme"), # a discriminator loadMVAfromDB = cms.bool(True), + inputFileName = cms.FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile"), # the filename for MVA if it is not loaded from DB + mvaOutput_normalization = cms.string(""), # the special value for not using a string parameter is empty string "" + # it's the same value as the atribute of this plugin class is initialized with anyway + # and throughout configs this parameter is everywhere set to non-empty value + mapping = cms.VPSet( cms.PSet( category = cms.uint32(0), @@ -32,5 +37,6 @@ category = cms.uint32(1), cut = cms.double(0.2), ), - ) + ), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py index f34e613ef66e1..ac6a52ccc9df6 100644 --- a/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py +++ b/RecoTauTag/RecoTau/python/PATTauDiscriminationAgainstElectronMVA6_cfi.py @@ -35,5 +35,6 @@ srcElectrons = cms.InputTag('slimmedElectrons'), vetoEcalCracks = cms.bool(True), - usePhiAtEcalEntranceExtrapolation = cms.bool(False) + usePhiAtEcalEntranceExtrapolation = cms.bool(False), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PATTauDiscriminationByMVAIsolationRun2_cff.py b/RecoTauTag/RecoTau/python/PATTauDiscriminationByMVAIsolationRun2_cff.py index e9b96a38171fd..b04e2cf84dfd7 100644 --- a/RecoTauTag/RecoTau/python/PATTauDiscriminationByMVAIsolationRun2_cff.py +++ b/RecoTauTag/RecoTau/python/PATTauDiscriminationByMVAIsolationRun2_cff.py @@ -13,16 +13,18 @@ PATTauProducer = cms.InputTag('replaceMeByTauCollectionToBeUsed'), # in MiniAOD: slimmedTaus Prediscriminants = noPrediscriminants, loadMVAfromDB = cms.bool(True), + inputFileName = cms.FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile"), # the filename for MVA if it is not loaded from DB mvaName = cms.string("replaceMeByNameOfMVATraining"), # e.g. RecoTauTag_tauIdMVADBoldDMwLTv1 mvaOpt = cms.string("replaceMeByMVAOption"), # e.g. DBoldDMwLT - requireDecayMode = cms.bool(True), # change these only if input isolation sums changed for the MVA training you want to use srcChargedIsoPtSum = cms.string('chargedIsoPtSum'), srcNeutralIsoPtSum = cms.string('neutralIsoPtSum'), srcPUcorrPtSum = cms.string('puCorrPtSum'), srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalCone'), - srcFootprintCorrection = cms.string('footprintCorrection') + srcFootprintCorrection = cms.string('footprintCorrection'), + + verbosity = cms.int32(0) ) patDiscriminationByIsolationMVArun2v1VLoose = patTauDiscriminantCutMultiplexer.clone( diff --git a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronBuilderPlugins_cfi.py index bbf3c25a52936..d1e9dea93c42b 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronBuilderPlugins_cfi.py @@ -33,7 +33,8 @@ maxUnmatchedBlockElementsPhoton = cms.int32(1), minMergeNeutralHadronEt = cms.double(1.0), minMergeGammaEt = cms.double(1.0), - minMergeChargedHadronPt = cms.double(100.) + minMergeChargedHadronPt = cms.double(100.), + verbosity = cms.int32(0) ) # Produce a ChargedHadron candidate for each reco::Track @@ -49,7 +50,8 @@ dRmergePhoton = cms.double(0.05), minMergeNeutralHadronEt = cms.double(1.0), minMergeGammaEt = cms.double(1.0), - minMergeChargedHadronPt = cms.double(100.) + minMergeChargedHadronPt = cms.double(100.), + verbosity = cms.int32(0) ) # Produce a ChargedHadron candidate for high Pt PFNeutralHadrons @@ -59,5 +61,6 @@ # process PFNeutralHadrons # (numbering scheme defined in DataFormats/ParticleFlowCandidate/interface/PFCandidate.h) chargedHadronCandidatesParticleIds = cms.vint32(5), - minMergeChargedHadronPt = cms.double(0.) + minMergeChargedHadronPt = cms.double(0.), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py index c0a9945729a76..c4db3a6374f98 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauChargedHadronProducer_cfi.py @@ -20,5 +20,6 @@ ranking.isChargedPFCandidate, ranking.isTrack, ranking.isPFNeutralHadron - ) + ), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectron2_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectron2_cfi.py index 4f49e810ccee8..f130bbc82fd47 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectron2_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectron2_cfi.py @@ -37,6 +37,7 @@ GammaEtaMom_endcap_max = cms.double(1.5), GammaPhiMom_endcap_max = cms.double(1.5), GammaEnFrac_endcap_max = cms.double(0.2), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi.py index fb56791a9afeb..f891f28f305d2 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi.py @@ -16,5 +16,6 @@ minStatus = cms.uint32(12), # region around dead/masked ECAL crystals that is to be cut - dR = cms.double(0.08) + dR = cms.double(0.08), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA5_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA5_cfi.py index 524157e446ec2..76972a0b810b5 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA5_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA5_cfi.py @@ -51,5 +51,6 @@ minMVAWgWOgsfEC = cms.double(0.0), minMVAWgWgsfEC = cms.double(0.0), - srcGsfElectrons = cms.InputTag('gedGsfElectrons') + srcGsfElectrons = cms.InputTag('gedGsfElectrons'), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA6_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA6_cfi.py index 853630277acb2..1fbb78e9f8577 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA6_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstElectronMVA6_cfi.py @@ -36,5 +36,6 @@ srcGsfElectrons = cms.InputTag('gedGsfElectrons'), vetoEcalCracks = cms.bool(True), - usePhiAtEcalEntranceExtrapolation = cms.bool(False) + usePhiAtEcalEntranceExtrapolation = cms.bool(False), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonMVA_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonMVA_cfi.py index f6c99d6b2f5eb..4d36338b1652e 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonMVA_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationAgainstMuonMVA_cfi.py @@ -12,10 +12,12 @@ # 2) a track OR a pi-zero in the signal cone has pT > 5 GeV Prediscriminants = requireLeadTrack, loadMVAfromDB = cms.bool(True), + inputFileName = cms.FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile"), # the filename for MVA if it is not loaded from DB mvaName = cms.string("againstMuonMVA"), returnMVA = cms.bool(True), mvaMin = cms.double(0.0), srcMuons = cms.InputTag('muons'), dRmuonMatch = cms.double(0.3), + verbosity = cms.int32(0), ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py index 59792be0ff6d0..40c7ac14366df 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByHPSSelection_cfi.py @@ -3,6 +3,10 @@ from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs +minPi0Mass_default = -1.e3 +maxPi0Mass_default = 1.e9 +assumeStripMass_default = -1.0 + decayMode_1Prong0Pi0 = cms.PSet( nCharged = cms.uint32(1), nPiZeros = cms.uint32(0), @@ -13,7 +17,10 @@ # negative mass. FIXME - investigate this minMass = cms.double(-1.e3), maxMass = cms.string("1."), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), # for XProng0Pi0 decay modes bending corrections are transparent + assumeStripMass = cms.double(assumeStripMass_default), applyBendCorrection = cms.PSet( eta = cms.bool(True), phi = cms.bool(True), @@ -27,6 +34,8 @@ nChargedPFCandsMin = cms.uint32(1), minMass = cms.double(0.3), maxMass = cms.string("max(1.3, min(1.3*sqrt(pt/100.), 4.2))"), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), assumeStripMass = cms.double(0.1349), applyBendCorrection = cms.PSet( eta = cms.bool(True), @@ -58,7 +67,10 @@ nChargedPFCandsMin = cms.uint32(1), minMass = cms.double(0.), maxMass = cms.string("1.2"), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), # for XProng0Pi0 decay modes bending corrections are transparent + assumeStripMass = cms.double(assumeStripMass_default), applyBendCorrection = cms.PSet( eta = cms.bool(False), phi = cms.bool(False), @@ -72,6 +84,9 @@ nChargedPFCandsMin = cms.uint32(1), minMass = cms.double(0.), maxMass = cms.string("max(1.2, min(1.2*sqrt(pt/100.), 4.0))"), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), + assumeStripMass = cms.double(assumeStripMass_default), applyBendCorrection = cms.PSet( eta = cms.bool(False), phi = cms.bool(False), @@ -85,6 +100,9 @@ nChargedPFCandsMin = cms.uint32(1), minMass = cms.double(0.8), maxMass = cms.string("1.5"), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), + assumeStripMass = cms.double(assumeStripMass_default), applyBendCorrection = cms.PSet( eta = cms.bool(False), phi = cms.bool(False), @@ -98,7 +116,10 @@ nChargedPFCandsMin = cms.uint32(1), minMass = cms.double(0.9), maxMass = cms.string("1.6"), + minPi0Mass = cms.double(minPi0Mass_default), + maxPi0Mass = cms.double(maxPi0Mass_default), # for XProng0Pi0 decay modes bending corrections are transparent + assumeStripMass = cms.double(assumeStripMass_default), applyBendCorrection = cms.PSet( eta = cms.bool(False), phi = cms.bool(False), @@ -123,7 +144,8 @@ ), requireTauChargedHadronsToBeChargedPFCands = cms.bool(False), # CV: require at least one pixel hit for the sum of all tracks - minPixelHits = cms.int32(1) + minPixelHits = cms.int32(1), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py index 93c3afe3f7f1a..f3524d2dcdaa5 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByIsolation_cfi.py @@ -41,6 +41,7 @@ vertexSrc = PFTauQualityCuts.primaryVertexSrc, # This must correspond to the cone size of the algorithm which built the # tau. (or if customOuterCone option is used, the custom cone size) + customOuterCone = cms.double(-1.), # propagated this default from .cc, it probably corresponds to not using customOuterCone isoConeSizeForDeltaBeta = cms.double(0.5), # The delta beta factor maps the expected neutral contribution in the # isolation cone from the observed PU charged contribution. This factor can @@ -50,8 +51,8 @@ # By default, the pt threshold for tracks used to compute the DeltaBeta # correction is taken as the gamma Et threshold from the isolation quality # cuts. - # Uncommenting the parameter below allows this threshold to be overridden. - #deltaBetaPUTrackPtCutOverride = cms.double(1.5), + deltaBetaPUTrackPtCutOverride = cms.bool(False), # Set the boolean = True to override. + deltaBetaPUTrackPtCutOverride_val = cms.double(-1.5), # Set the value for new value. # Tau footprint correction applyFootprintCorrection = cms.bool(False), @@ -84,6 +85,13 @@ rhoConeSize = cms.double(0.5), rhoUEOffsetCorrection = cms.double(1.0), UseAllPFCandsForWeights = cms.bool(False), - verbosity = cms.int32(0) - + + # moved these from .cc ifExists structures + storeRawOccupancy = cms.bool(False), + storeRawSumPt = cms.bool(False), + storeRawPUsumPt = cms.bool(False), + storeRawFootprintCorrection = cms.bool(False), + storeRawPhotonSumPt_outsideSignalCone = cms.bool(False), + + verbosity = cms.int32(0), ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolation2_cff.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolation2_cff.py index fb2aaecb3e0c8..8f11c271a628e 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolation2_cff.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolation2_cff.py @@ -53,6 +53,7 @@ # 2) a track OR a pi-zero in the signal cone has pT > 5 GeV Prediscriminants = requireLeadTrack, loadMVAfromDB = cms.bool(True), + inputFileName = cms.FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile"), # the filename for MVA if it is not loaded from DB mvaName = cms.string("tauIdMVAnewDMwLT"), mvaOpt = cms.string("newDMwLT"), @@ -61,7 +62,9 @@ srcChargedIsoPtSum = cms.InputTag('chargedIsoPtSum'), srcNeutralIsoPtSum = cms.InputTag('neutralIsoPtSum'), - srcPUcorrPtSum = cms.InputTag('puCorrPtSum') + srcPUcorrPtSum = cms.InputTag('puCorrPtSum'), + + verbosity = cms.int32(0) ) discriminationByIsolationMVA2VLoose = recoTauDiscriminantCutMultiplexer.clone( diff --git a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolationRun2_cff.py b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolationRun2_cff.py index cd230ead12675..5d45cc7b6f3eb 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolationRun2_cff.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauDiscriminationByMVAIsolationRun2_cff.py @@ -68,6 +68,7 @@ # 2) a track OR a pi-zero in the signal cone has pT > 5 GeV Prediscriminants = requireLeadTrack, loadMVAfromDB = cms.bool(True), + inputFileName = cms.FileInPath("RecoTauTag/RecoTau/data/emptyMVAinputFile"), # the filename for MVA if it is not loaded from DB mvaName = cms.string("tauIdMVAnewDMwLT"), mvaOpt = cms.string("newDMwLT"), @@ -78,7 +79,9 @@ srcNeutralIsoPtSum = cms.InputTag('neutralIsoPtSum'), srcPUcorrPtSum = cms.InputTag('puCorrPtSum'), srcPhotonPtSumOutsideSignalCone = cms.InputTag('photonPtSumOutsideSignalCone'), - srcFootprintCorrection = cms.InputTag('footprintCorrection') + srcFootprintCorrection = cms.InputTag('footprintCorrection'), + + verbosity = cms.int32(0) ) discriminationByIsolationMVArun2v1VLoose = recoTauDiscriminantCutMultiplexer.clone( diff --git a/RecoTauTag/RecoTau/python/PFRecoTauEnergyAlgorithmPlugin_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauEnergyAlgorithmPlugin_cfi.py index 93ae37daa6ffc..611e2e30aa3af 100644 --- a/RecoTauTag/RecoTau/python/PFRecoTauEnergyAlgorithmPlugin_cfi.py +++ b/RecoTauTag/RecoTau/python/PFRecoTauEnergyAlgorithmPlugin_cfi.py @@ -4,5 +4,6 @@ dRaddNeutralHadron = cms.double(0.12), # CV: enabled adding PFNeutralHadrons minNeutralHadronEt = cms.double(50.), dRaddPhoton = cms.double(-1.), # CV: disabled adding PFGammas - minGammaEt = cms.double(10.) + minGammaEt = cms.double(10.), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py b/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py deleted file mode 100644 index 08453080bb408..0000000000000 --- a/RecoTauTag/RecoTau/python/PFRecoTauProducer_cfi.py +++ /dev/null @@ -1,111 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from RecoTauTag.RecoTau.PFRecoTauQualityCuts_cfi import PFTauQualityCuts - -pfRecoTauProducer = cms.EDProducer("PFRecoTauProducer", - - Algorithm = cms.string("ConeBased"), - LeadPFCand_minPt = cms.double(5.0), #cut on lead object (can be track, or gamma) - - #SignalCone parameters - TrackerSignalConeMetric = cms.string('DR'), ## * - TrackerSignalConeSizeFormula = cms.string('0.07'), ## ** - TrackerSignalConeSize_min = cms.double(0.0), - - #Important: the four-vector energy for the PFTau is defined as the candidates - # within the maximum tracker signal cone size (TrackerSignalConeSize_max_). - # For fixed cone taus, this should be set to the fixed cone size. - TrackerSignalConeSize_max = cms.double(0.07), - - ECALSignalConeMetric = cms.string('DR'), ## * - ECALSignalConeSizeFormula = cms.string('0.15'), ## ** - ECALSignalConeSize_min = cms.double(0.0), - ECALSignalConeSize_max = cms.double(0.6), - - HCALSignalConeMetric = cms.string('DR'), ## * - HCALSignalConeSizeFormula = cms.string('0.10'), ## ** - HCALSignalConeSize_min = cms.double(0.0), - HCALSignalConeSize_max = cms.double(0.6), - - #IsolationCone parameters - TrackerIsolConeMetric = cms.string('DR'), ## * - TrackerIsolConeSizeFormula = cms.string('0.50'), ## ** - TrackerIsolConeSize_min = cms.double(0.0), - TrackerIsolConeSize_max = cms.double(0.6), - - ECALIsolConeMetric = cms.string('DR'), ## * - ECALIsolConeSizeFormula = cms.string('0.50'), ## ** - ECALIsolConeSize_min = cms.double(0.0), - ECALIsolConeSize_max = cms.double(0.6), - - HCALIsolConeMetric = cms.string('DR'), ## * - HCALIsolConeSizeFormula = cms.string('0.50'), ## ** - HCALIsolConeSize_min = cms.double(0.0), - HCALIsolConeSize_max = cms.double(0.6), - - # Cut on the number of tracker hits on isolation PF charged hadrons - #ChargedHadrCand_IsolAnnulus_minNhits = cms.uint32(8), # this cut is now applied in the PFTauDiscriminator - ChargedHadrCand_IsolAnnulus_minNhits = cms.uint32(0), - - #Electron rejection parameters - ElectronPreIDProducer = cms.InputTag("elecpreid"), - EcalStripSumE_deltaPhiOverQ_minValue = cms.double(-0.1), - EcalStripSumE_deltaPhiOverQ_maxValue = cms.double(0.5), - EcalStripSumE_minClusEnergy = cms.double(0.1), - EcalStripSumE_deltaEta = cms.double(0.03), - ElecPreIDLeadTkMatch_maxDR = cms.double(0.01), - maximumForElectrionPreIDOutput = cms.double(-0.1), - - #Lead track matching cone parameters - MatchingConeMetric = cms.string('DR'), - MatchingConeSizeFormula = cms.string('0.1'), - MatchingConeSize_min = cms.double(0.0), #min/max don't affect, as it is locked at 0.1 - MatchingConeSize_max = cms.double(0.6), #just make sure they window 0.1! - - # PFTaus are seeded by TauTagInfos (basically a jet wrapper/quality filter) - PFTauTagInfoProducer = cms.InputTag("pfRecoTauTagInfoProducer"), - JetPtMin = cms.double(0.0), - #Filter lead charged hadron cand. by DZ to vertex? - UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint = cms.bool(True), - ChargedHadrCandLeadChargedHadrCand_tksmaxDZ = cms.double(1.0), - - #Standard PV stuff - PVProducer = PFTauQualityCuts.primaryVertexSrc, - smearedPVsigmaY = cms.double(0.0015), - smearedPVsigmaX = cms.double(0.0015), - smearedPVsigmaZ = cms.double(0.005), - - #FixedArea parameters - AreaMetric_recoElements_maxabsEta = cms.double(2.5), - - DataType = cms.string("AOD"), # Computring tier (modifies how some values are retrieved..) - - # The following parameters affect TRACKS ONLY. - # i.e., they use tracks, from the jet tracks associator, not PFChargedHadronCandidates - # Intended only as a cross check, don't use them unles syou need them! - - # Track - PV filtering - LeadTrack_minPt = cms.double(0.0), # This should be cut on at the discriminator level, - # to make things consistent in the case where the tau - # has a leading PFGamma cand but no lead PFChargedCand - TrackLeadTrack_maxDZ = cms.double(1.0), - UseTrackLeadTrackDZconstraint = cms.bool(True), - Track_IsolAnnulus_minNhits = cms.uint32(3), - ### parameters for gammas in ellipse ### - AddEllipseGammas = cms.bool(False), - Rphi = cms.double(2.0), ## factor*Reta; Reta is the standard ecal signal cone size - MaxEtInEllipse = cms.double(2.0), # max pt for gammas inside the ellipse - ######################################## - - # If true, include signal cone neutral hadrons in the tau four vector. - # Note: alternatLorentzVector is always only charged + gamma - putNeutralHadronsInP4 = cms.bool(False), - -) - # * possible metrics : "DR", "angle", "area"; - # if the "area" metric is chosen, AreaMetric_recoElements_maxabsEta parameter is considered, the area of a cone is increased by increasing the angle of the cone; - # functionnality to use a "DR" signal cone and an "area" isolation outer cone is not available; - # ** may depend on E(energy) and/or PT(transverse momentum) of the initial PFJet, ex. : "3.0/E" or "3.0/ET" - # if XXXConeSizeFormula>XXXConeSize_max then XXXConeSize_max is the considered cone size ; if XXXConeSizeFormula 18.0 & abs(eta)<2.3") ) diff --git a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py index b2e191d225e06..a67ff5eebb0f1 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleanerPlugins.py @@ -6,6 +6,8 @@ ''' +tolerance_default = cms.double(0) + matchingConeCut = cms.PSet( name = cms.string("MatchingCone"), plugin = cms.string("RecoTauStringCleanerPlugin"), @@ -13,6 +15,7 @@ selection = cms.string("deltaR(eta, phi, jetRef().eta, jetRef().phi) < 0.1"), selectionPassFunction = cms.string("0"), selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) # Prefer taus with charge == 1 (no three prongs with charge = 3) @@ -26,6 +29,7 @@ # If it is a one prong, consider it just as good as a # three prong with unit charge selectionFailValue = cms.double(0), + tolerance = tolerance_default, ) # similar to unitCharge but handles also cases where tau is made up of @@ -38,6 +42,7 @@ # taus with charge != 1 are rejected passForCharge = cms.int32(1), selectionFailValue = cms.double(0), + tolerance = tolerance_default, ) # Prefer taus with pt greater 15 @@ -46,7 +51,8 @@ plugin = cms.string("RecoTauStringCleanerPlugin"), selection = cms.string("pt > 15."), selectionPassFunction = cms.string("0"), - selectionFailValue = cms.double(1e3) + selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) # Prefer taus that have higher TaNC output values @@ -54,12 +60,14 @@ name = cms.string("TaNC"), plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), src = cms.InputTag("DISCRIMINATOR_SRC"), + tolerance = tolerance_default, ) leadPionFinding = cms.PSet( name = cms.string("LeadPion"), plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), src = cms.InputTag("DISCRIMINATOR_SRC"), + tolerance = tolerance_default, ) pt = cms.PSet( @@ -74,7 +82,8 @@ chargedHadronMultiplicity = cms.PSet( name = cms.string("ChargedHadronMultiplicity"), - plugin = cms.string("RecoTauChargedHadronMultiplicityCleanerPlugin") + plugin = cms.string("RecoTauChargedHadronMultiplicityCleanerPlugin"), + tolerance = tolerance_default, ) stripMultiplicity = cms.PSet( @@ -83,7 +92,8 @@ # Require that cones were built by ensuring the a leadCand exits selection = cms.string("leadPFCand().isNonnull()"), selectionPassFunction = cms.string("-signalPiZeroCandidates().size()"), - selectionFailValue = cms.double(1e3) + selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) combinedIsolation = cms.PSet( @@ -92,7 +102,8 @@ # Require that cones were built by ensuring the a leadCand exits selection = cms.string("leadPFCand().isNonnull()"), selectionPassFunction = cms.string("isolationPFChargedHadrCandsPtSum() + isolationPFGammaCandsEtSum()"), - selectionFailValue = cms.double(1e3) + selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) chargeIsolation = cms.PSet( @@ -102,7 +113,8 @@ selection = cms.string("leadPFCand().isNonnull()"), # Prefer lower isolation activity selectionPassFunction = cms.string("isolationPFChargedHadrCandsPtSum()"), - selectionFailValue = cms.double(1e3) + selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) ecalIsolation = cms.PSet( @@ -112,7 +124,8 @@ selection = cms.string("leadPFCand().isNonnull()"), # Prefer lower isolation activity selectionPassFunction = cms.string("isolationPFGammaCandsEtSum()"), - selectionFailValue = cms.double(1e3) + selectionFailValue = cms.double(1e3), + tolerance = tolerance_default, ) # CV: Reject 2-prong candidates in which one of the tracks has low pT, @@ -120,5 +133,6 @@ killSoftTwoProngTaus = cms.PSet( name = cms.string("killSoftTwoProngTaus"), plugin = cms.string("RecoTauSoftTwoProngTausCleanerPlugin"), - minTrackPt = cms.double(5.) + minTrackPt = cms.double(5.), + tolerance = tolerance_default, ) diff --git a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py index d0dc26deeec9a..537330b8039a0 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCleaner_cfi.py @@ -14,6 +14,7 @@ name = cms.string("HPS_Select"), plugin = cms.string("RecoTauDiscriminantCleanerPlugin"), src = cms.InputTag("hpsSelectionDiscriminator"), + tolerance = cms.double(0), ), # CV: Reject 2-prong candidates in which one of the tracks has low pT, # in order to reduce rate of 1-prong taus migrating to 2-prong decay mode @@ -26,6 +27,8 @@ # prefer candidates in which PFGammas are part of strips (rather than being merged with PFRecoTauChargedHadrons) cleaners.stripMultiplicity, # Take most isolated tau - cleaners.combinedIsolation - ) + cleaners.combinedIsolation, + ), + outputSelection = cms.string(""), # empty string is special value for doing nothing in the plugin + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py index f599808795bd1..c849ae67a7400 100644 --- a/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauCombinatoricProducer_cfi.py @@ -104,7 +104,6 @@ pfTauEnergyAlgorithmPlugin, name = cms.string("tau_en_reconstruction"), plugin = cms.string("PFRecoTauEnergyAlgorithmPlugin"), - verbosity = cms.int32(0) ) ] @@ -127,7 +126,8 @@ minAbsPhotonSumPt_insideSignalCone = cms.double(2.5), minRelPhotonSumPt_insideSignalCone = cms.double(0.10), minAbsPhotonSumPt_outsideSignalCone = cms.double(1.e+9), # CV: always require at least some photon energy inside signal cone - minRelPhotonSumPt_outsideSignalCone = cms.double(1.e+9) # for a tau to be reconstructed in a decay mode with pi0s + minRelPhotonSumPt_outsideSignalCone = cms.double(1.e+9), # for a tau to be reconstructed in a decay mode with pi0s + verbosity = cms.int32(0) ) combinatoricRecoTaus = cms.EDProducer("RecoTauProducer", diff --git a/RecoTauTag/RecoTau/python/RecoTauDiscriminantConfiguration.py b/RecoTauTag/RecoTau/python/RecoTauDiscriminantConfiguration.py index a73ca194a23fc..8526553267ef6 100644 --- a/RecoTauTag/RecoTau/python/RecoTauDiscriminantConfiguration.py +++ b/RecoTauTag/RecoTau/python/RecoTauDiscriminantConfiguration.py @@ -4,9 +4,10 @@ FlightPathSignificance = cms.PSet( plugin = cms.string("RecoTauDiscriminantFromDiscriminator"), - discSrc = cms.InputTag('hpsTancTausDiscriminationByFlightPath'), + discSrc = cms.VInputTag(cms.InputTag('hpsTancTausDiscriminationByFlightPath')), minValue = cms.double(-25), maxValue = cms.double(25), + takeAbs = cms.bool(False), ), InvariantOpeningAngle = cms.PSet( diff --git a/RecoTauTag/RecoTau/python/RecoTauDiscriminantCutMultiplexer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauDiscriminantCutMultiplexer_cfi.py index ff96a51661e61..cbbfcd0f88282 100644 --- a/RecoTauTag/RecoTau/python/RecoTauDiscriminantCutMultiplexer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauDiscriminantCutMultiplexer_cfi.py @@ -9,20 +9,11 @@ ''' import FWCore.ParameterSet.Config as cms +from RecoTauTag.RecoTau.recoTauDiscriminantCutMultiplexerDefault_cfi import recoTauDiscriminantCutMultiplexerDefault -recoTauDiscriminantCutMultiplexer = cms.EDProducer( - "RecoTauDiscriminantCutMultiplexer", +recoTauDiscriminantCutMultiplexer = recoTauDiscriminantCutMultiplexerDefault.clone( PFTauProducer = cms.InputTag("fixme"), toMultiplex = cms.InputTag("fixme"), - Prediscriminants = cms.PSet( - BooleanOperator = cms.string("and"), - decayMode = cms.PSet( - Producer = cms.InputTag("fixme"), - cut = cms.double(0.) - ) - ), - key = cms.InputTag("fixme"), # a discriminator - loadMVAfromDB = cms.bool(True), mapping = cms.VPSet( cms.PSet( category = cms.uint32(0), diff --git a/RecoTauTag/RecoTau/python/RecoTauFixedConeProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauFixedConeProducer_cfi.py index a7b79e2e1cf09..f510ed3bab4bb 100644 --- a/RecoTauTag/RecoTau/python/RecoTauFixedConeProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauFixedConeProducer_cfi.py @@ -28,7 +28,8 @@ isoConeNeutralHadrons = cms.string('0.4'), maxSignalConeChargedHadrons = cms.int32(-1), # CV: upper limit on number of signalConeChargedHadrons disabled per default minAbsPhotonSumPt_insideSignalCone = cms.double(2.5), - minRelPhotonSumPt_insideSignalCone = cms.double(0.10) + minRelPhotonSumPt_insideSignalCone = cms.double(0.10), + verbosity = cms.int32(0) ) fixedConeRecoTaus = shrinkingConeRecoTaus.clone( diff --git a/RecoTauTag/RecoTau/python/RecoTauJetRegionProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauJetRegionProducer_cfi.py index 142e22668358e..cb328872f5442 100644 --- a/RecoTauTag/RecoTau/python/RecoTauJetRegionProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauJetRegionProducer_cfi.py @@ -9,5 +9,6 @@ minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, pfCandSrc = cms.InputTag("particleFlow"), - pfCandAssocMapSrc = cms.InputTag("") + pfCandAssocMapSrc = cms.InputTag(""), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py index 036ba51bcde3f..40f475cb2a4dd 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroBuilderPlugins_cfi.py @@ -64,30 +64,37 @@ minGammaEtStripAdd = cms.double(1.0), minStripEt = cms.double(1.0), updateStripAfterEachDaughter = cms.bool(False), - maxStripBuildIterations = cms.int32(-1) + maxStripBuildIterations = cms.int32(-1), + verbosity = cms.int32(0) ) # Produce a "strips" of photons # with no track quality cuts applied to PFElectrons # and eta x phi size of strip increasing for low pT photons -modStrips2 = strips.clone( + +modStrips2 = cms.PSet( + name = cms.string("s"), plugin = cms.string('RecoTauPiZeroStripPlugin3'), applyElecTrackQcuts = cms.bool(False), - minGammaEtStripSeed = cms.double(1.0), - minGammaEtStripAdd = cms.double(1.0), - minStripEt = cms.double(1.0), - # CV: parametrization of strip size in eta and phi determined by Yuta Takahashi, - # chosen to contain 95% of photons from tau decays - stripEtaAssociationDistance = cms.PSet( + # Clusterize photons and electrons (PF numbering) + stripCandidatesParticleIds = cms.vint32(2, 4), + stripEtaAssociationDistanceFunc = cms.PSet( function = cms.string("TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"), par0 = cms.double(1.97077e-01), par1 = cms.double(6.58701e-01) ), - stripPhiAssociationDistance = cms.PSet( + stripPhiAssociationDistanceFunc = cms.PSet( function = cms.string("TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))"), par0 = cms.double(3.52476e-01), par1 = cms.double(7.07716e-01) ), + makeCombinatoricStrips = cms.bool(False), + minGammaEtStripSeed = cms.double(1.0), + minGammaEtStripAdd = cms.double(1.0), + minStripEt = cms.double(1.0), + # CV: parametrization of strip size in eta and phi determined by Yuta Takahashi, + # chosen to contain 95% of photons from tau decays updateStripAfterEachDaughter = cms.bool(False), - maxStripBuildIterations = cms.int32(-1) + maxStripBuildIterations = cms.int32(-1), + verbosity = cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py index 1b3a060af37c7..b4c8752295d7a 100644 --- a/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauPiZeroProducer_cfi.py @@ -5,13 +5,12 @@ from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs from Configuration.Eras.Modifier_phase2_common_cff import phase2_common -ak4PFJetsLegacyHPSPiZeros = cms.EDProducer( - "RecoTauPiZeroProducer", + +from RecoTauTag.RecoTau.ak4PFJetsLegacyHPSPiZerosDefault_cfi import ak4PFJetsLegacyHPSPiZerosDefault +ak4PFJetsLegacyHPSPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, - massHypothesis = cms.double(0.136), - outputSelection = cms.string('pt > 0'), builders = cms.VPSet( #builders.strips #builders.modStrips @@ -19,12 +18,14 @@ ), ranking = cms.VPSet( ranking.isInStrip - ) + ), ) phase2_common.toModify(ak4PFJetsLegacyHPSPiZeros, builders = cms.VPSet(builders.modStrips) ) -ak4PFJetsRecoTauGreedyPiZeros = ak4PFJetsLegacyHPSPiZeros.clone( +from RecoTauTag.RecoTau.ak4PFJetsRecoTauGreedyPiZerosDefault_cfi import ak4PFJetsRecoTauGreedyPiZerosDefault +#ak4PFJetsRecoTauGreedyPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( +ak4PFJetsRecoTauGreedyPiZeros = ak4PFJetsRecoTauGreedyPiZerosDefault.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -38,7 +39,9 @@ ), ) -ak4PFJetsRecoTauPiZeros = ak4PFJetsLegacyHPSPiZeros.clone( +from RecoTauTag.RecoTau.ak4PFJetsRecoTauPiZerosDefault_cfi import ak4PFJetsRecoTauPiZerosDefault +#ak4PFJetsRecoTauPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( +ak4PFJetsRecoTauPiZeros = ak4PFJetsRecoTauPiZerosDefault.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, @@ -57,11 +60,12 @@ ), ) -ak4PFJetsLegacyTaNCPiZeros = ak4PFJetsLegacyHPSPiZeros.clone( +from RecoTauTag.RecoTau.ak4PFJetsLegacyTaNCPiZerosDefault_cfi import ak4PFJetsLegacyTaNCPiZerosDefault +# ak4PFJetsLegacyTaNCPiZeros = ak4PFJetsLegacyHPSPiZerosDefault.clone( +ak4PFJetsLegacyTaNCPiZeros = ak4PFJetsLegacyTaNCPiZerosDefault.clone( jetSrc = PFRecoTauPFJetInputs.inputJetCollection, minJetPt = PFRecoTauPFJetInputs.minJetPt, maxJetAbsEta = PFRecoTauPFJetInputs.maxJetAbsEta, - massHypothesis = cms.double(0.136), outputSelection = cms.string('pt > 1.5'), builders = cms.VPSet( builders.allSinglePhotons, diff --git a/RecoTauTag/RecoTau/python/RecoTauShrinkingConeProducer_cfi.py b/RecoTauTag/RecoTau/python/RecoTauShrinkingConeProducer_cfi.py index 4b277aa215104..7d50690be4403 100644 --- a/RecoTauTag/RecoTau/python/RecoTauShrinkingConeProducer_cfi.py +++ b/RecoTauTag/RecoTau/python/RecoTauShrinkingConeProducer_cfi.py @@ -27,7 +27,8 @@ isoConeNeutralHadrons = cms.string('0.4'), maxSignalConeChargedHadrons = cms.int32(-1), # CV: upper limit on number of signalConeChargedHadrons disabled per default minAbsPhotonSumPt_insideSignalCone = cms.double(2.5), - minRelPhotonSumPt_insideSignalCone = cms.double(0.10) + minRelPhotonSumPt_insideSignalCone = cms.double(0.10), + verbosity = cms.int32(0) ) shrinkingConeRecoTaus = combinatoricRecoTaus.clone( diff --git a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py index dbf29ab2ae830..3b7f1a62d2df8 100644 --- a/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py +++ b/RecoTauTag/RecoTau/python/tools/runTauIdMVA.py @@ -145,7 +145,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs mvaOpt = self.cms.string("DBoldDMwLTwGJ"), - requireDecayMode = self.cms.bool(True), verbosity = self.cms.int32(0) ) @@ -228,7 +227,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs mvaOpt = self.cms.string("DBoldDMwLTwGJ"), - requireDecayMode = self.cms.bool(True), verbosity = self.cms.int32(0) ) @@ -311,7 +309,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2017v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs mvaOpt = self.cms.string("DBnewDMwLTwGJ"), - requireDecayMode = self.cms.bool(True), verbosity = self.cms.int32(0) ) @@ -394,7 +391,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT2017v2"), mvaOpt = self.cms.string("DBoldDMwLTwGJ"), - requireDecayMode = self.cms.bool(True), srcChargedIsoPtSum = self.cms.string('chargedIsoPtSumdR03'), srcFootprintCorrection = self.cms.string('footprintCorrectiondR03'), srcNeutralIsoPtSum = self.cms.string('neutralIsoPtSumdR03'), @@ -461,7 +457,6 @@ def runTauID(self): # loadMVAfromDB = self.cms.bool(True), # mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v2"),#RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1 writeTauIdDiscrMVAs # mvaOpt = self.cms.string("DBoldDMwLTwGJ"), - # requireDecayMode = self.cms.bool(True), # verbosity = self.cms.int32(0) # ) # # @@ -489,7 +484,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"), mvaOpt = self.cms.string("DBoldDMwLT"), - requireDecayMode = self.cms.bool(True), verbosity = self.cms.int32(0) ) @@ -548,7 +542,6 @@ def runTauID(self): loadMVAfromDB = self.cms.bool(True), mvaName = self.cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT2016v1"), mvaOpt = self.cms.string("DBnewDMwLT"), - requireDecayMode = self.cms.bool(True), verbosity = self.cms.int32(0) ) diff --git a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc index eafd4d0e53218..5c2ae188e6354 100644 --- a/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc +++ b/RecoTauTag/RecoTau/src/AntiElectronIDMVA6.cc @@ -1338,12 +1338,12 @@ bool AntiElectronIDMVA6::atECalEntrance(const reco::Candidate* part, math::XYZPo math::XYZTLorentzVector(part->vertex().x(), part->vertex().y(), part->vertex().z(), - 0.)), + 0.), + part->charge()), 0.,0.,bField_); - theParticle.setCharge(part->charge()); theParticle.propagateToEcalEntrance(false); if(theParticle.getSuccess()!=0){ - pos = math::XYZPoint(theParticle.vertex()); + pos = math::XYZPoint(theParticle.particle().vertex()); result = true; } else { diff --git a/RecoTauTag/RecoTau/src/TauDiscriminationProducerBase.cc b/RecoTauTag/RecoTau/src/TauDiscriminationProducerBase.cc index d834d18bc85ef..81de9ffad163b 100644 --- a/RecoTauTag/RecoTau/src/TauDiscriminationProducerBase.cc +++ b/RecoTauTag/RecoTau/src/TauDiscriminationProducerBase.cc @@ -156,6 +156,28 @@ void TauDiscriminationProducerBase::produce(edm::Even endEvent(event); } +template +void TauDiscriminationProducerBase::fillProducerDescriptions(edm::ParameterSetDescription& desc) { + // helper function, it fills the description of the Producers parameter + desc.add(getProducerString(),edm::InputTag("fixme")); + { + edm::ParameterSetDescription pset_prediscriminants; + pset_prediscriminants.add("BooleanOperator","AND"); + // optional producers // will it pass if I don't specify them? + + { + edm::ParameterSetDescription producer_params; + producer_params.add("cut",0.); + producer_params.add("Producer",edm::InputTag("fixme")); + + pset_prediscriminants.addOptional("leadTrack", producer_params); + pset_prediscriminants.addOptional("decayMode", producer_params); + } + + desc.add("Prediscriminants", pset_prediscriminants); + } +} + // template specialiazation to get the correct (Calo/PF)TauProducer names template<> std::string getProducerString() { return "PFTauProducer"; } template<> std::string getProducerString() { return "CaloTauProducer"; } diff --git a/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py b/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py index a1da648c05ec8..0e410c3e06b00 100644 --- a/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py +++ b/RecoTauTag/RecoTau/test/rerunMVAIsolationOnMiniAOD.py @@ -41,7 +41,6 @@ ## run with new MVA training mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"), mvaOpt = cms.string("DBoldDMwLT"), - requireDecayMode = cms.bool(True), verbosity = cms.int32(0) ) diff --git a/RecoTracker/IterativeTracking/python/DetachedQuadStep_cff.py b/RecoTracker/IterativeTracking/python/DetachedQuadStep_cff.py index c019e8ebd4168..2bf62b5eab5b7 100644 --- a/RecoTracker/IterativeTracking/python/DetachedQuadStep_cff.py +++ b/RecoTracker/IterativeTracking/python/DetachedQuadStep_cff.py @@ -2,6 +2,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ############################################### # Low pT and detached tracks from pixel quadruplets ############################################### @@ -203,26 +206,27 @@ fastSim.toModify(detachedQuadStepTracks,TTRHBuilder = 'WithoutRefit') # TRACK SELECTION AND QUALITY FLAG SETTING. -from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * -from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -detachedQuadStep = TrackLwtnnClassifier.clone( +from RecoTracker.FinalTrackSelectors.TrackMVAClassifierDetached_cfi import * +detachedQuadStep = TrackMVAClassifierDetached.clone( + mva = dict(GBRForestLabel = 'MVASelectorDetachedQuadStep_Phase1'), src = 'detachedQuadStepTracks', - qualityCuts = [-0.6, 0.05, 0.7], + qualityCuts = [-0.5,0.0,0.5] ) -fastSim.toModify(detachedQuadStep,vertices = "firstStepPrimaryVerticesBeforeMixing") -from RecoTracker.FinalTrackSelectors.TrackMVAClassifierDetached_cfi import * -highBetaStar_2018.toReplaceWith(detachedQuadStep, TrackMVAClassifierDetached.clone( +from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * +from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * +trackdnn.toReplaceWith(detachedQuadStep, TrackLwtnnClassifier.clone( src = 'detachedQuadStepTracks', - qualityCuts = [-0.7,0.0,0.5], - mva = dict(GBRForestLabel = 'MVASelectorDetachedQuadStep_Phase1') + qualityCuts = [-0.6, 0.05, 0.7] )) -pp_on_AA_2018.toReplaceWith(detachedQuadStep, TrackMVAClassifierDetached.clone( - src = 'detachedQuadStepTracks', - qualityCuts = [-0.2, 0.2, 0.5], - mva = dict(GBRForestLabel = 'HIMVASelectorDetachedQuadStep_Phase1') -)) +highBetaStar_2018.toModify(detachedQuadStep,qualityCuts = [-0.7,0.0,0.5]) +pp_on_AA_2018.toModify(detachedQuadStep, + mva = dict(GBRForestLabel = 'HIMVASelectorDetachedQuadStep_Phase1'), + qualityCuts = [-0.2, 0.2, 0.5], +) + +fastSim.toModify(detachedQuadStep,vertices = "firstStepPrimaryVerticesBeforeMixing") # For Phase2PU140 import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/DetachedTripletStep_cff.py b/RecoTracker/IterativeTracking/python/DetachedTripletStep_cff.py index 4ea0504931705..2b1d89109f72c 100644 --- a/RecoTracker/IterativeTracking/python/DetachedTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/DetachedTripletStep_cff.py @@ -6,6 +6,8 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim from FastSimulation.Tracking.SeedingMigration import _hitSetProducerToFactoryPSet +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn ############################################### # Low pT and detached tracks from pixel triplets @@ -252,26 +254,24 @@ detachedTripletStep = ClassifierMerger.clone() detachedTripletStep.inputClassifiers=['detachedTripletStepClassifier1','detachedTripletStepClassifier2'] +trackingPhase1.toReplaceWith(detachedTripletStep, detachedTripletStepClassifier1.clone( + mva = dict(GBRForestLabel = 'MVASelectorDetachedTripletStep_Phase1'), + qualityCuts = [-0.2,0.3,0.8] +)) -#LWTNN selector from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(detachedTripletStep, TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(detachedTripletStep, TrackLwtnnClassifier.clone( src = 'detachedTripletStepTracks', qualityCuts = [0.0, 0.4, 0.8], )) -(trackingPhase1 & fastSim).toModify(detachedTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") - -highBetaStar_2018.toReplaceWith(detachedTripletStep, detachedTripletStepClassifier1.clone( - qualityCuts = [-0.5,0.0,0.5], - mva = dict(GBRForestLabel = 'MVASelectorDetachedTripletStep_Phase1') -)) - -pp_on_AA_2018.toReplaceWith(detachedTripletStep, detachedTripletStepClassifier1.clone( - qualityCuts = [-0.2, 0.4, 0.85], - mva = dict(GBRForestLabel = 'HIMVASelectorDetachedTripletStep_Phase1') -)) +(trackdnn & fastSim).toModify(detachedTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +highBetaStar_2018.toModify(detachedTripletStep,qualityCuts = [-0.5,0.0,0.5]) +pp_on_AA_2018.toModify(detachedTripletStep, + mva = dict(GBRForestLabel = 'HIMVASelectorDetachedTripletStep_Phase1'), + qualityCuts = [-0.2, 0.4, 0.85], +) # For LowPU import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index 4b5c9eeac44a5..b6e7e2fdab44a 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -2,6 +2,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ### high-pT triplets ### # NEW CLUSTERS (remove previously used clusters) @@ -244,27 +247,27 @@ fastSim.toModify(highPtTripletStepTracks,TTRHBuilder = 'WithoutRefit') # Final selection +from RecoTracker.FinalTrackSelectors.TrackMVAClassifierPrompt_cfi import * +highPtTripletStep = TrackMVAClassifierPrompt.clone( + mva = dict(GBRForestLabel = 'MVASelectorHighPtTripletStep_Phase1'), + src = 'highPtTripletStepTracks', + qualityCuts = [0.2,0.3,0.4] +) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -highPtTripletStep = TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(highPtTripletStep, TrackLwtnnClassifier.clone( src = 'highPtTripletStepTracks', qualityCuts = [0.75, 0.775, 0.8], -) -fastSim.toModify(highPtTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") - -from RecoTracker.FinalTrackSelectors.TrackMVAClassifierPrompt_cfi import * - -highBetaStar_2018.toReplaceWith(highPtTripletStep, TrackMVAClassifierPrompt.clone( - qualityCuts = [-0.2,0.3,0.4], - src = 'highPtTripletStepTracks', - mva = dict(GBRForestLabel = 'MVASelectorDetachedTripletStep_Phase1') )) -pp_on_AA_2018.toReplaceWith(highPtTripletStep, TrackMVAClassifierPrompt.clone( - qualityCuts = [-0.9, -0.3, 0.85], - src = 'highPtTripletStepTracks', - mva = dict(GBRForestLabel = 'HIMVASelectorHighPtTripletStep_Phase1') -)) +highBetaStar_2018.toModify(highPtTripletStep,qualityCuts = [-0.2,0.3,0.4]) +pp_on_AA_2018.toModify(highPtTripletStep, + mva = dict(GBRForestLabel = 'HIMVASelectorHighPtTripletStep_Phase1'), + qualityCuts = [-0.9, -0.3, 0.85], +) + +fastSim.toModify(highPtTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") # For Phase2PU140 import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/InitialStep_cff.py b/RecoTracker/IterativeTracking/python/InitialStep_cff.py index c3514fa4a8263..b09078ec64ab9 100644 --- a/RecoTracker/IterativeTracking/python/InitialStep_cff.py +++ b/RecoTracker/IterativeTracking/python/InitialStep_cff.py @@ -2,6 +2,9 @@ from Configuration.Eras.Modifier_tracker_apv_vfp30_2016_cff import tracker_apv_vfp30_2016 as _tracker_apv_vfp30_2016 from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ### STEP 0 ### # hit building @@ -290,19 +293,23 @@ initialStep = ClassifierMerger.clone() initialStep.inputClassifiers=['initialStepClassifier1','initialStepClassifier2','initialStepClassifier3'] -#LWTNN selector +trackingPhase1.toReplaceWith(initialStep, initialStepClassifier1.clone( + mva = dict(GBRForestLabel = 'MVASelectorInitialStep_Phase1'), + qualityCuts = [-0.95,-0.85,-0.75] +)) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(initialStep, TrackLwtnnClassifier.clone( - src = 'initialStepTracks', - qualityCuts = [0.0, 0.3, 0.6], +trackdnn.toReplaceWith(initialStep, TrackLwtnnClassifier.clone( + src = 'initialStepTracks', + qualityCuts = [0.0, 0.3, 0.6] )) -(trackingPhase1 & fastSim).toModify(initialStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +(trackdnn & fastSim).toModify(initialStep,vertices = "firstStepPrimaryVerticesBeforeMixing") -pp_on_AA_2018.toReplaceWith(initialStep, initialStepClassifier1.clone( - qualityCuts = [-0.9, -0.5, 0.2], - mva = dict(GBRForestLabel = 'HIMVASelectorInitialStep_Phase1') -)) +pp_on_AA_2018.toModify(initialStep, + mva = dict(GBRForestLabel = 'HIMVASelectorInitialStep_Phase1'), + qualityCuts = [-0.9, -0.5, 0.2], +) # For LowPU and Phase2PU140 import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/JetCoreRegionalStep_cff.py b/RecoTracker/IterativeTracking/python/JetCoreRegionalStep_cff.py index 18de06b618012..a02f9713daf0e 100644 --- a/RecoTracker/IterativeTracking/python/JetCoreRegionalStep_cff.py +++ b/RecoTracker/IterativeTracking/python/JetCoreRegionalStep_cff.py @@ -1,5 +1,8 @@ import FWCore.ParameterSet.Config as cms +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + # This step runs over all clusters # run only if there are high pT jets @@ -187,16 +190,20 @@ from RecoTracker.FinalTrackSelectors.TrackMVAClassifierPrompt_cfi import * -fastSim.toModify(jetCoreRegionalStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +trackingPhase1.toReplaceWith(jetCoreRegionalStep, TrackMVAClassifierPrompt.clone( + mva = dict(GBRForestLabel = 'MVASelectorJetCoreRegionalStep_Phase1'), + src = 'jetCoreRegionalStepTracks', + qualityCuts = [-0.2,0.0,0.4] +)) -#LWTNN selector from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(jetCoreRegionalStep, TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(jetCoreRegionalStep, TrackLwtnnClassifier.clone( src = 'jetCoreRegionalStepTracks', qualityCuts = [0.6, 0.7, 0.8], )) -(trackingPhase1 & fastSim).toModify(jetCoreRegionalStep,vertices = "firstStepPrimaryVerticesBeforeMixing") + +fastSim.toModify(jetCoreRegionalStep,vertices = "firstStepPrimaryVerticesBeforeMixing") # Final sequence JetCoreRegionalStepTask = cms.Task(jetsForCoreTracking, diff --git a/RecoTracker/IterativeTracking/python/LowPtQuadStep_cff.py b/RecoTracker/IterativeTracking/python/LowPtQuadStep_cff.py index 50c458be6b4ac..0293e43a7c361 100644 --- a/RecoTracker/IterativeTracking/python/LowPtQuadStep_cff.py +++ b/RecoTracker/IterativeTracking/python/LowPtQuadStep_cff.py @@ -2,6 +2,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + # NEW CLUSTERS (remove previously used clusters) lowPtQuadStepClusters = _cfg.clusterRemoverForIter("LowPtQuadStep") for _eraName, _postfix, _era in _cfg.nonDefaultEras(): @@ -195,27 +198,27 @@ # Final selection -from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * -from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -lowPtQuadStep = TrackLwtnnClassifier.clone( - src = 'lowPtQuadStepTracks', - qualityCuts = [0.2, 0.425, 0.75], -) -fastSim.toModify(lowPtQuadStep,vertices = "firstStepPrimaryVerticesBeforeMixing") - from RecoTracker.FinalTrackSelectors.TrackMVAClassifierPrompt_cfi import * +lowPtQuadStep = TrackMVAClassifierPrompt.clone( + mva = dict(GBRForestLabel = 'MVASelectorLowPtQuadStep_Phase1'), + src = 'lowPtQuadStepTracks', + qualityCuts = [-0.7,-0.35,-0.15] +) -highBetaStar_2018.toReplaceWith(lowPtQuadStep, TrackMVAClassifierPrompt.clone( +from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * +from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * +trackdnn.toReplaceWith(lowPtQuadStep, TrackLwtnnClassifier.clone( src = 'lowPtQuadStepTracks', - qualityCuts = [-0.9,-0.35,-0.15], - mva = dict(GBRForestLabel = 'MVASelectorDetachedTripletStep_Phase1') + qualityCuts = [0.2, 0.425, 0.75] )) -pp_on_AA_2018.toReplaceWith(lowPtQuadStep, TrackMVAClassifierPrompt.clone( - src = 'lowPtQuadStepTracks', - qualityCuts = [-0.9, -0.4, 0.3], - mva = dict(GBRForestLabel = 'HIMVASelectorLowPtQuadStep_Phase1') -)) +highBetaStar_2018.toModify(lowPtQuadStep,qualityCuts = [-0.9,-0.35,-0.15]) +pp_on_AA_2018.toModify(lowPtQuadStep, + mva = dict(GBRForestLabel = 'HIMVASelectorLowPtQuadStep_Phase1'), + qualityCuts = [-0.9, -0.4, 0.3], +) + +fastSim.toModify(lowPtQuadStep,vertices = "firstStepPrimaryVerticesBeforeMixing") # For Phase2PU140 import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py index 04dae2c6be890..879b648f32658 100644 --- a/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/LowPtTripletStep_cff.py @@ -3,6 +3,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + # NEW CLUSTERS (remove previously used clusters) lowPtTripletStepClusters = _cfg.clusterRemoverForIter("LowPtTripletStep") for _eraName, _postfix, _era in _cfg.nonDefaultEras(): @@ -274,26 +277,24 @@ lowPtTripletStep.mva.GBRForestLabel = 'MVASelectorIter1_13TeV' lowPtTripletStep.qualityCuts = [-0.6,-0.3,-0.1] -#LWTNN selector +trackingPhase1.toReplaceWith(lowPtTripletStep, lowPtTripletStep.clone( + mva = dict(GBRForestLabel = 'MVASelectorLowPtTripletStep_Phase1'), + qualityCuts = [-0.4,0.0,0.3], +)) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(lowPtTripletStep, TrackLwtnnClassifier.clone( - src = 'lowPtTripletStepTracks', - qualityCuts = [0.2, 0.5, 0.8], +trackdnn.toReplaceWith(lowPtTripletStep, TrackLwtnnClassifier.clone( + src = 'lowPtTripletStepTracks', + qualityCuts = [0.2, 0.5, 0.8] )) +highBetaStar_2018.toModify(lowPtTripletStep,qualityCuts = [-0.7,-0.3,-0.1]) +pp_on_AA_2018.toModify(lowPtTripletStep, + mva = dict(GBRForestLabel = 'HIMVASelectorLowPtTripletStep_Phase1'), + qualityCuts = [-0.8, -0.4, 0.5], +) fastSim.toModify(lowPtTripletStep, vertices = "firstStepPrimaryVerticesBeforeMixing") -highBetaStar_2018.toReplaceWith(lowPtTripletStep, TrackMVAClassifierPrompt.clone( - src = 'lowPtTripletStepTracks', - qualityCuts = [-0.7,-0.3,-0.1], - mva = dict(GBRForestLabel = 'MVASelectorLowPtTripletStep_Phase1') -)) - -pp_on_AA_2018.toReplaceWith(lowPtTripletStep, TrackMVAClassifierPrompt.clone( - src = 'lowPtTripletStepTracks', - qualityCuts = [-0.8, -0.4, 0.5], - mva = dict(GBRForestLabel = 'HIMVASelectorLowPtTripletStep_Phase1') -)) # For LowPU and Phase2PU140 import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/MixedTripletStep_cff.py b/RecoTracker/IterativeTracking/python/MixedTripletStep_cff.py index 2cf50f8353552..967ad6b17ae2e 100644 --- a/RecoTracker/IterativeTracking/python/MixedTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/MixedTripletStep_cff.py @@ -2,6 +2,10 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim + +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ############################################################### # Large impact parameter Tracking using mixed-triplet seeding # ############################################################### @@ -337,25 +341,21 @@ mixedTripletStep = ClassifierMerger.clone() mixedTripletStep.inputClassifiers=['mixedTripletStepClassifier1','mixedTripletStepClassifier2'] -#LWTNN selector +trackingPhase1.toReplaceWith(mixedTripletStep, mixedTripletStepClassifier1.clone( + mva = dict(GBRForestLabel = 'MVASelectorMixedTripletStep_Phase1'), + qualityCuts = [-0.5,0.0,0.5] +)) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(mixedTripletStep, TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(mixedTripletStep, TrackLwtnnClassifier.clone( src = 'mixedTripletStepTracks', - qualityCuts = [-0.8, -0.35, 0.1], -)) -(trackingPhase1 & fastSim).toModify(mixedTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") - -highBetaStar_2018.toReplaceWith(mixedTripletStep, mixedTripletStepClassifier1.clone( - qualityCuts = [-0.7,0.0,0.5], - mva = dict(GBRForestLabel = 'MVASelectorMixedTripletStep_Phase1') -)) - -pp_on_AA_2018.toReplaceWith(mixedTripletStep, mixedTripletStepClassifier1.clone( - qualityCuts = [-0.5,0.0,0.9], - mva = dict(GBRForestLabel = 'MVASelectorMixedTripletStep_Phase1') + qualityCuts = [-0.8, -0.35, 0.1] )) +(trackdnn & fastSim).toModify(mixedTripletStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +highBetaStar_2018.toModify(mixedTripletStep,qualityCuts = [-0.7,0.0,0.5]) +pp_on_AA_2018.toModify(mixedTripletStep, qualityCuts = [-0.5,0.0,0.9]) # For LowPU import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py index d5691fc7060c6..56866dfcb8dca 100644 --- a/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelLessStep_cff.py @@ -2,6 +2,10 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim + +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ########################################################################## # Large impact parameter tracking using TIB/TID/TEC stereo layer seeding # ########################################################################## @@ -288,19 +292,20 @@ from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 -#LWTNN selector +trackingPhase1.toReplaceWith(pixelLessStep, pixelLessStepClassifier1.clone( + mva = dict(GBRForestLabel = 'MVASelectorPixelLessStep_Phase1'), + qualityCuts = [-0.4,0.0,0.4] +)) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(pixelLessStep, TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(pixelLessStep, TrackLwtnnClassifier.clone( src = 'pixelLessStepTracks', - qualityCuts = [-0.6, -0.05, 0.5], + qualityCuts = [-0.6, -0.05, 0.5] )) -(trackingPhase1 & fastSim).toModify(pixelLessStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +(trackdnn & fastSim).toModify(pixelLessStep,vertices = "firstStepPrimaryVerticesBeforeMixing") -pp_on_AA_2018.toReplaceWith(pixelLessStep, pixelLessStepClassifier1.clone( - qualityCuts = [-0.4,0.0,0.8], - mva = dict(GBRForestLabel = 'MVASelectorPixelLessStep_Phase1') -)) +pp_on_AA_2018.toModify(pixelLessStep, qualityCuts = [-0.4,0.0,0.8]) # For LowPU import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py index 21f6ea7fbede5..5356db99d6198 100644 --- a/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py +++ b/RecoTracker/IterativeTracking/python/PixelPairStep_cff.py @@ -3,6 +3,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + # NEW CLUSTERS (remove previously used clusters) pixelPairStepClusters = _cfg.clusterRemoverForIter("PixelPairStep") for _eraName, _postfix, _era in _cfg.nonDefaultEras(): @@ -333,30 +336,19 @@ pixelPairStep.mva.GBRForestLabel = 'MVASelectorIter2_13TeV' pixelPairStep.qualityCuts = [-0.2,0.0,0.3] -#LWTNN selector +trackingPhase1.toModify(pixelPairStep, mva=dict(GBRForestLabel = 'MVASelectorPixelPairStep_Phase1')) + from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(pixelPairStep, TrackLwtnnClassifier.clone( - src='pixelPairStepTracks', - qualityCuts=[-0.6, -0.1, 0.4], -)) - -highBetaStar_2018.toReplaceWith(pixelPairStep, TrackMVAClassifierPrompt.clone( +trackdnn.toReplaceWith(pixelPairStep, TrackLwtnnClassifier.clone( src='pixelPairStepTracks', - qualityCuts = [-0.95,0.0,0.3], - mva=dict(GBRForestLabel = 'MVASelectorPixelPairStep_Phase1') -)) - -pp_on_AA_2018.toReplaceWith(pixelPairStep, TrackMVAClassifierPrompt.clone( - src='pixelPairStepTracks', - qualityCuts = [-0.2, 0.0, 0.9], - mva=dict(GBRForestLabel = 'MVASelectorPixelPairStep_Phase1') + qualityCuts=[-0.6, -0.1, 0.4] )) +highBetaStar_2018.toModify(pixelPairStep,qualityCuts = [-0.95,0.0,0.3]) +pp_on_AA_2018.toModify(pixelPairStep, qualityCuts = [-0.2, 0.0, 0.98]) fastSim.toModify(pixelPairStep, vertices = "firstStepPrimaryVerticesBeforeMixing") - - # For LowPU and Phase2PU140 import RecoTracker.IterativeTracking.LowPtTripletStep_cff import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi diff --git a/RecoTracker/IterativeTracking/python/TobTecStep_cff.py b/RecoTracker/IterativeTracking/python/TobTecStep_cff.py index de224315ad1d9..95da4355b9cfc 100644 --- a/RecoTracker/IterativeTracking/python/TobTecStep_cff.py +++ b/RecoTracker/IterativeTracking/python/TobTecStep_cff.py @@ -2,6 +2,9 @@ import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg from Configuration.Eras.Modifier_fastSim_cff import fastSim +#for dnn classifier +from Configuration.ProcessModifiers.trackdnn_cff import trackdnn + ####################################################################### # Very large impact parameter tracking using TOB + TEC ring 5 seeding # ####################################################################### @@ -361,22 +364,20 @@ tobTecStep.inputClassifiers=['tobTecStepClassifier1','tobTecStepClassifier2'] from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 +trackingPhase1.toReplaceWith(tobTecStep, tobTecStepClassifier1.clone( + mva = dict(GBRForestLabel = 'MVASelectorTobTecStep_Phase1'), + qualityCuts = [-0.6,-0.45,-0.3] +)) -#LWTNN selector from RecoTracker.FinalTrackSelectors.TrackLwtnnClassifier_cfi import * from RecoTracker.FinalTrackSelectors.trackSelectionLwtnn_cfi import * -trackingPhase1.toReplaceWith(tobTecStep, TrackLwtnnClassifier.clone( +trackdnn.toReplaceWith(tobTecStep, TrackLwtnnClassifier.clone( src = 'tobTecStepTracks', qualityCuts = [-0.4, -0.25, -0.1] )) -(trackingPhase1 & fastSim).toModify(tobTecStep,vertices = "firstStepPrimaryVerticesBeforeMixing") - -pp_on_AA_2018.toReplaceWith(tobTecStep, TrackMVAClassifierDetached.clone( - src = 'tobTecStepTracks', - qualityCuts = [-0.6,-0.3,0.7], - mva = dict(GBRForestLabel = 'MVASelectorTobTecStep_Phase1') -)) +(trackdnn & fastSim).toModify(tobTecStep,vertices = "firstStepPrimaryVerticesBeforeMixing") +pp_on_AA_2018.toModify(tobTecStep, qualityCuts = [-0.6,-0.3,0.7]) import RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi trackingLowPU.toReplaceWith(tobTecStep, RecoTracker.FinalTrackSelectors.multiTrackSelector_cfi.multiTrackSelector.clone( diff --git a/RecoTracker/IterativeTracking/python/customise_MVAPhase1_cfi.py b/RecoTracker/IterativeTracking/python/customise_MVAPhase1_cfi.py deleted file mode 100644 index 5747013263e3f..0000000000000 --- a/RecoTracker/IterativeTracking/python/customise_MVAPhase1_cfi.py +++ /dev/null @@ -1,87 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from RecoTracker.FinalTrackSelectors.TrackMVAClassifierPrompt_cfi import * -from RecoTracker.FinalTrackSelectors.TrackMVAClassifierDetached_cfi import * -from RecoTracker.IterativeTracking.InitialStep_cff import * -from RecoTracker.IterativeTracking.DetachedQuadStep_cff import * -from RecoTracker.IterativeTracking.DetachedTripletStep_cff import * -from RecoTracker.IterativeTracking.HighPtTripletStep_cff import * -from RecoTracker.IterativeTracking.JetCoreRegionalStep_cff import * -from RecoTracker.IterativeTracking.LowPtQuadStep_cff import * -from RecoTracker.IterativeTracking.LowPtTripletStep_cff import * -from RecoTracker.IterativeTracking.MixedTripletStep_cff import * -from RecoTracker.IterativeTracking.PixelPairStep_cff import * -from RecoTracker.IterativeTracking.PixelLessStep_cff import * -from RecoTracker.IterativeTracking.TobTecStep_cff import * - -from Configuration.StandardSequences.Eras import eras -from Configuration.Eras.Modifier_trackingPhase1_cff import trackingPhase1 - - -def customise_MVAPhase1(process): - trackingPhase1.toReplaceWith(detachedQuadStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorDetachedQuadStep_Phase1'), - src = 'detachedQuadStepTracks', - qualityCuts = [-0.5,0.0,0.5] - )) - - trackingPhase1.toReplaceWith(detachedTripletStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorDetachedTripletStep_Phase1'), - src = 'detachedTripletStepTracks', - qualityCuts = [-0.2,0.3,0.8] - )) - - trackingPhase1.toReplaceWith(highPtTripletStep, TrackMVAClassifierPrompt.clone( - mva = dict(GBRForestLabel = 'MVASelectorHighPtTripletStep_Phase1'), - src = 'highPtTripletStepTracks', - qualityCuts = [0.2,0.3,0.4] - )) - - trackingPhase1.toReplaceWith(initialStep, TrackMVAClassifierPrompt.clone( - mva = dict(GBRForestLabel = 'MVASelectorInitialStep_Phase1'), - src = 'initialStepTracks', - qualityCuts = [-0.95,-0.85,-0.75] - )) - - trackingPhase1.toReplaceWith(jetCoreRegionalStep, TrackMVAClassifierPrompt.clone( - mva = dict(GBRForestLabel = 'MVASelectorJetCoreRegionalStep_Phase1'), - src = 'jetCoreRegionalStepTracks', - qualityCuts = [-0.2,0.0,0.4] - )) - - trackingPhase1.toReplaceWith(lowPtQuadStep, TrackMVAClassifierPrompt.clone( - mva = dict(GBRForestLabel = 'MVASelectorLowPtQuadStep_Phase1'), - src = 'lowPtQuadStepTracks', - qualityCuts = [-0.7,-0.35,-0.15] - )) - - trackingPhase1.toReplaceWith(lowPtTripletStep, TrackMVAClassifierPrompt.clone( - mva = dict(GBRForestLabel = 'MVASelectorLowPtTripletStep_Phase1'), - src = 'lowPtTripletStepTracks', - qualityCuts = [-0.4,0.0,0.3] - )) - - trackingPhase1.toReplaceWith(mixedTripletStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorMixedTripletStep_Phase1'), - src = 'mixedTripletStepTracks', - qualityCuts = [-0.5,0.0,0.5] - )) - - trackingPhase1.toReplaceWith(pixelLessStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorPixelLessStep_Phase1'), - src = 'pixelLessStepTracks', - qualityCuts = [-0.4,0.0,0.4] - )) - - trackingPhase1.toReplaceWith(pixelPairStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorPixelPairStep_Phase1'), - src = 'pixelPairStepTracks', - qualityCuts = [-0.2,0.0,0.3] - )) - - trackingPhase1.toReplaceWith(tobTecStep, TrackMVAClassifierDetached.clone( - mva = dict(GBRForestLabel = 'MVASelectorTobTecStep_Phase1'), - src = 'tobTecStepTracks', - qualityCuts = [-0.6,-0.45,-0.3] - )) - - return process diff --git a/RecoTracker/TkNavigation/plugins/SimpleNavigableLayer.cc b/RecoTracker/TkNavigation/plugins/SimpleNavigableLayer.cc index fd6edfd4000cb..7bb86da07ebb9 100644 --- a/RecoTracker/TkNavigation/plugins/SimpleNavigableLayer.cc +++ b/RecoTracker/TkNavigation/plugins/SimpleNavigableLayer.cc @@ -222,7 +222,7 @@ std::vector< const DetLayer * > SimpleNavigableLayer::compatibleLayers (const Fr typedef std::set Lset; //initiate the first iteration - Lvect && someLayers = nextLayers(fts,timeDirection); + const Lvect & someLayers = nextLayers(fts,timeDirection); if (someLayers.empty()) { LogDebug("SimpleNavigableLayer") <<"Number of compatible layers: "<< 0; return someLayers; diff --git a/RecoTracker/TransientTrackingRecHit/test/TTRHBuilderTest.cc b/RecoTracker/TransientTrackingRecHit/test/TTRHBuilderTest.cc index 989c110797659..0500cce1c4223 100644 --- a/RecoTracker/TransientTrackingRecHit/test/TTRHBuilderTest.cc +++ b/RecoTracker/TransientTrackingRecHit/test/TTRHBuilderTest.cc @@ -46,8 +46,8 @@ class TTRHBuilderTest : public edm::EDAnalyzer { edm::ESHandle theB; setup.get().get(cpeName,theB); - - cout <<" Got a "<stripClusterParameterEstimator()<pixelClusterParameterEstimator()<& vtx, double energy_total = sqrt(par(3)*par(3)+par(6)*par(6) + par(5)*par(5)+par(4)*par(4)); - std::vector::const_iterator rs; std::vector::const_iterator rt_i; int i_int = 0; for(rt_i = refTracks.begin(); rt_i != refTracks.end(); rt_i++) diff --git a/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.cc b/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.cc index 1e5da016bb9d9..2b0c8561afee9 100644 --- a/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.cc +++ b/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.cc @@ -206,7 +206,7 @@ EcalSelectiveReadout::getTowerInterest(const EcalTrigTowerDetId & tower) const : tower.ieta() + nTriggerTowersInEta/2 -1; int iPhi = tower.iphi() - 1; - assert(-1 <= towerInterest[iEta][iPhi] && towerInterest[iEta][iPhi] < 8); + assert(-1 <= towerInterest[iEta][iPhi] && int(towerInterest[iEta][iPhi]) < 8); return towerInterest[iEta][iPhi]; } diff --git a/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadoutSuppressor.cc b/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadoutSuppressor.cc index b185702e18c69..60b44fbc24482 100644 --- a/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadoutSuppressor.cc +++ b/SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadoutSuppressor.cc @@ -308,7 +308,7 @@ EcalSelectiveReadoutSuppressor::run(const edm::EventSetup& eventSetup, for(EBDigiCollection::const_iterator digiItr = barrelDigis.begin(); digiItr != barrelDigis.end(); ++digiItr){ int interestLevel - = ecalSelectiveReadout->getCrystalInterest(EBDigiCollection::DetId(digiItr->id())) && ~EcalSelectiveReadout::FORCED_MASK; + = ecalSelectiveReadout->getCrystalInterest(EBDigiCollection::DetId(digiItr->id())) & ~EcalSelectiveReadout::FORCED_MASK; if(accept(*digiItr, zsThreshold[BARREL][interestLevel])){ selectedBarrelDigis->push_back(digiItr->id(), digiItr->begin()); } diff --git a/SimDataFormats/GeneratorProducts/src/classes_def.xml b/SimDataFormats/GeneratorProducts/src/classes_def.xml index a25e750a10083..c3a00478db98d 100644 --- a/SimDataFormats/GeneratorProducts/src/classes_def.xml +++ b/SimDataFormats/GeneratorProducts/src/classes_def.xml @@ -15,8 +15,9 @@ hepmc_rootio::clear_particles_in(newObj); ]]> - + + diff --git a/SimG4CMS/Calo/src/HcalNumberingFromPS.cc b/SimG4CMS/Calo/src/HcalNumberingFromPS.cc index 8fdf93e0522e7..483f457b3a5d9 100644 --- a/SimG4CMS/Calo/src/HcalNumberingFromPS.cc +++ b/SimG4CMS/Calo/src/HcalNumberingFromPS.cc @@ -8,7 +8,6 @@ #include //#define EDM_ML_DEBUG -using namespace geant_units; using namespace geant_units::operators; HcalNumberingFromPS::HcalNumberingFromPS(const edm::ParameterSet& conf) { diff --git a/SimG4CMS/Calo/test/python/runHGC4_cfg.py b/SimG4CMS/Calo/test/python/runHGC4_cfg.py index 949090d56d39a..d71bebb99667a 100644 --- a/SimG4CMS/Calo/test/python/runHGC4_cfg.py +++ b/SimG4CMS/Calo/test/python/runHGC4_cfg.py @@ -5,6 +5,8 @@ process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") #process.load("Configuration.Geometry.GeometryExtended2023D28_cff") process.load("Geometry.HGCalCommonData.testHGCV10XML_cfi") +process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi") +process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi") process.load("Configuration.StandardSequences.MagneticField_cff") process.load("Configuration.EventContent.EventContent_cff") process.load('Configuration.StandardSequences.Generator_cff') diff --git a/SimG4CMS/Forward/interface/FastTimerSD.h b/SimG4CMS/Forward/interface/FastTimerSD.h index ef37d48e56d42..98db23e012a77 100644 --- a/SimG4CMS/Forward/interface/FastTimerSD.h +++ b/SimG4CMS/Forward/interface/FastTimerSD.h @@ -31,6 +31,7 @@ class FastTimerSD : public TimingSD, protected: + using TimingSD::update; void update(const BeginOfJob *) override; private: diff --git a/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h b/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h deleted file mode 100644 index 720da79515bb5..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/AHCalSD.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SimG4CMS_AHCalSD_h -#define SimG4CMS_AHCalSD_h - -#include "SimG4CMS/Calo/interface/CaloSD.h" - -#include -#include - -class G4Step; - -class AHCalSD : public CaloSD { - -public: - - AHCalSD(const std::string& , const DDCompactView &, const SensitiveDetectorCatalog &, - edm::ParameterSet const &, const SimTrackManager*); - ~AHCalSD() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - bool unpackIndex(const uint32_t & idx, int & row, - int& col, int& depth); -protected: - - double getEnergyDeposit(const G4Step*) override; - bool filterHit(CaloG4Hit*, double) override; - -private: - - bool useBirk; - double birk1, birk2, birk3, betaThr; - double eminHit; -}; - -#endif // AHCalSD_h diff --git a/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h b/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h deleted file mode 100644 index c24786d20e713..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SimG4CMS_HGCalTB16SD01_h -#define SimG4CMS_HGCalTB16SD01_h -/////////////////////////////////////////////////////////////////////////////// -// File: HGCalTB16SD01.h -// Description: Stores hits of Beam counters for Fermilab TB16 in appropriate -// containers -/////////////////////////////////////////////////////////////////////////////// - -#include "SimG4CMS/Calo/interface/CaloSD.h" - -#include - -class DDCompactView; -class G4Step; -class G4Material; - -class HGCalTB16SD01 : public CaloSD { - -public: - - HGCalTB16SD01(const std::string& , const DDCompactView &, - const SensitiveDetectorCatalog &, edm::ParameterSet const &, - const SimTrackManager*); - ~HGCalTB16SD01() override = default; - uint32_t setDetUnitId(const G4Step* step) override; - static uint32_t packIndex(int det, int lay, int x, int y); - static void unpackIndex(const uint32_t & idx, int& det, int& lay, - int& x, int& y); - -protected: - - double getEnergyDeposit(const G4Step*) override; - -private: - void initialize(const G4StepPoint* point); - - std::string matName_; - bool useBirk_; - double birk1_, birk2_, birk3_; - bool initialize_; - G4Material* matScin_; -}; - -#endif // HGCalTB16SD01_h diff --git a/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h b/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h deleted file mode 100644 index bb53bd0ea830d..0000000000000 --- a/SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef SimG4CMS_HGCalTestBeam_HGCalTBMB_h -#define SimG4CMS_HGCalTestBeam_HGCalTBMB_h - -#include "SimG4Core/Watcher/interface/SimWatcher.h" -#include "SimG4Core/Notification/interface/Observer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -class BeginOfTrack; -class G4Step; -class EndOfTrack; -class G4VTouchable; - -#include -#include -#include - -class HGCalTBMB : public SimWatcher, - public Observer, - public Observer, - public Observer { - -public: - - HGCalTBMB(const edm::ParameterSet&); - ~HGCalTBMB() override; - -private: - - HGCalTBMB(const HGCalTBMB&) = delete; // stop default - const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... - - void update(const BeginOfTrack*) override; - void update(const G4Step*) override; - void update(const EndOfTrack*) override; - - bool stopAfter(const G4Step*); - int findVolume(const G4VTouchable* touch, bool stop) const; - - std::vector listNames_; - std::string stopName_; - double stopZ_; - unsigned int nList_; - std::vector radLen_, intLen_, stepLen_; - std::vector me100_, me200_, me300_; -}; - -#endif diff --git a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc index 81265db76feb9..be9a434143a4e 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/AHCalSD.cc @@ -1,6 +1,7 @@ -#include "SimG4CMS/HGCalTestBeam/interface/AHCalSD.h" +#include "SimG4CMS/Calo/interface/CaloSD.h" #include "SimG4CMS/HGCalTestBeam/interface/AHCalDetId.h" #include "SimG4Core/Notification/interface/TrackInformation.h" + #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/HcalDetId/interface/HcalDetId.h" @@ -15,8 +16,34 @@ #include "G4PhysicalConstants.hh" #include +#include +#include + //#define EDM_ML_DEBUG +class AHCalSD : public CaloSD { + +public: + + AHCalSD(const std::string& , const DDCompactView &, + const SensitiveDetectorCatalog &, + edm::ParameterSet const &, const SimTrackManager*); + ~AHCalSD() override = default; + uint32_t setDetUnitId(const G4Step* step) override; + bool unpackIndex(const uint32_t & idx, int & row, + int& col, int& depth); +protected: + + double getEnergyDeposit(const G4Step*) override; + bool filterHit(CaloG4Hit*, double) override; + +private: + + bool useBirk; + double birk1, birk2, birk3, betaThr; + double eminHit; +}; + AHCalSD::AHCalSD(const std::string& name, const DDCompactView & cpv, const SensitiveDetectorCatalog & clg, edm::ParameterSet const & p, const SimTrackManager* manager) : @@ -31,11 +58,11 @@ AHCalSD::AHCalSD(const std::string& name, const DDCompactView & cpv, birk3 = m_HC.getParameter("BirkC3"); eminHit = m_HC.getParameter("EminHit")*CLHEP::MeV; - edm::LogInfo("HcalSim") << "AHCalSD:: Use of Birks law is set to " - << useBirk << " with three constants kB = " - << birk1 << ", C1 = " << birk2 << ", C2 = " << birk3 - << "\nAHCalSD:: Threshold for storing hits: " - << eminHit << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD:: Use of Birks law is set to " + << useBirk << " with three constants kB = " + << birk1 << ", C1 = " << birk2 << ", C2 = " + << birk3 << "\nAHCalSD:: Threshold for storing" + << " hits: " << eminHit; } double AHCalSD::getEnergyDeposit(const G4Step* aStep) { @@ -48,8 +75,8 @@ double AHCalSD::getEnergyDeposit(const G4Step* aStep) { #endif if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3); #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: weight " << weight0 << " " << weight - << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " + << weight; #endif double edep = weight*destep; return edep; @@ -69,15 +96,15 @@ uint32_t AHCalSD::setDetUnitId(const G4Step * aStep) { int row = (jnrow == 0) ? inrow : -inrow; uint32_t index = AHCalDetId(row,col,depth).rawId(); #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: det = " << HcalOther - << " depth = " << depth << " row = " << row - << " column = " << col << " packed index = 0x" - << std::hex << index << std::dec << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: det = " << HcalOther + << " depth = " << depth << " row = " << row + << " column = " << col << " packed index = 0x" + << std::hex << index << std::dec; bool flag = unpackIndex(index, row, col, depth); - edm::LogInfo("HcalSim") << "Results from unpacker for 0x" << std::hex - << index << std::dec << " Flag " << flag << " Row " - << row << " Col " << col << " Depth " << depth - << std::endl; + edm::LogVerbatim("HcalSim") << "Results from unpacker for 0x" << std::hex + << index << std::dec << " Flag " << flag + << " Row " << row << " Col " << col << " Depth " + << depth; #endif return index; } @@ -94,9 +121,10 @@ bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) { depth = AHCalDetId(idx).depth(); } #ifdef EDM_ML_DEBUG - edm::LogInfo("HcalSim") << "AHCalSD: packed index = 0x" << std::hex << idx - << std::dec << " Row " << row << " Column " << col - << " Depth " << depth << " OK " << rcode << std::endl; + edm::LogVerbatim("HcalSim") << "AHCalSD: packed index = 0x" << std::hex + << idx << std::dec << " Row " << row + << " Column " << col << " Depth " << depth + << " OK " << rcode; #endif return rcode; } @@ -104,3 +132,11 @@ bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) { bool AHCalSD::filterHit(CaloG4Hit* aHit, double time) { return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit)); } + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" + +typedef AHCalSD AHcalSensitiveDetector; +DEFINE_SENSITIVEDETECTOR(AHcalSensitiveDetector); + diff --git a/SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc similarity index 59% rename from SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc rename to SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc index e40e90299e058..ba7a95bc74311 100644 --- a/SimG4CMS/HGCalTestBeam/src/HGCalTB16SD01.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTB16SD01.cc @@ -1,9 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// -// File: HGCalTB16SD01.cc -// Description: Sensitive Detector class for beam counters in TB06 setup -/////////////////////////////////////////////////////////////////////////////// - -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h" +#include "SimG4CMS/Calo/interface/CaloSD.h" #include "SimG4Core/Notification/interface/TrackInformation.h" #include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" @@ -19,9 +14,39 @@ #include "G4LogicalVolumeStore.hh" #include "CLHEP/Units/GlobalSystemOfUnits.h" +#include + //#define EDM_ML_DEBUG -HGCalTB16SD01::HGCalTB16SD01(const std::string& name, const DDCompactView & cpv, +class HGCalTB16SD01 : public CaloSD { + +public: + + HGCalTB16SD01(const std::string& , const DDCompactView &, + const SensitiveDetectorCatalog &, edm::ParameterSet const &, + const SimTrackManager*); + ~HGCalTB16SD01() override = default; + uint32_t setDetUnitId(const G4Step* step) override; + static uint32_t packIndex(int det, int lay, int x, int y); + static void unpackIndex(const uint32_t & idx, int& det, int& lay, + int& x, int& y); + +protected: + + double getEnergyDeposit(const G4Step*) override; + +private: + void initialize(const G4StepPoint* point); + + std::string matName_; + bool useBirk_; + double birk1_, birk2_, birk3_; + bool initialize_; + G4Material* matScin_; +}; + +HGCalTB16SD01::HGCalTB16SD01(const std::string& name, + const DDCompactView & cpv, const SensitiveDetectorCatalog & clg, edm::ParameterSet const & p, const SimTrackManager* manager) : @@ -36,10 +61,10 @@ HGCalTB16SD01::HGCalTB16SD01(const std::string& name, const DDCompactView & cpv, birk3_ = m_HC.getParameter("BirkC3"); matScin_ = nullptr; - edm::LogInfo("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " - << useBirk_ << " for " << matName_ - << " with three constants kB = " << birk1_ - << ", C1 = " << birk2_ << ", C2 = " << birk3_; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " + << useBirk_ << " for " << matName_ + << " with three constants kB = " << birk1_ + << ", C1 = " << birk2_ << ", C2 = " << birk3_; } double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) { @@ -53,10 +78,10 @@ double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) { weight *= getAttenuation(aStep, birk1_, birk2_, birk3_); } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Detector " - << point->GetTouchable()->GetVolume()->GetName() << " with " - << point->GetMaterial()->GetName() << " weight " << weight - << ":" << wt2 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " + << point->GetTouchable()->GetVolume()->GetName() + << " with " << point->GetMaterial()->GetName() + << " weight " << weight << ":" << wt2; #endif return weight*destep; } @@ -86,9 +111,10 @@ uint32_t HGCalTB16SD01::packIndex(int det, int lay, int x, int y) { idx += (ixx&511); //bits 0-8 #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Detector " << det << " Layer " << lay << " x " - << x << " " << ix << " " << ixx << " y " << y << " " << iy << " " - << iyy << " ID " << std::hex << idx << std::dec << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << det << " Layer " + << lay << " x " << x << " " << ix << " " << ixx + << " y " << y << " " << iy << " " << iyy << " ID " + << std::hex << idx << std::dec; #endif return idx; } @@ -109,7 +135,14 @@ void HGCalTB16SD01::initialize(const G4StepPoint* point) { initialize_ = false; } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTB16SD01: Material pointer for " << matName_ - << " is initialized to : " << matScin_ << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Material pointer for " + << matName_ << " is initialized to : " <("DoPassive",false); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ << " Digis = " - << doDigis_ << ":" << sampleIndex_ << " RecHits = " << doRecHits_ - << " useDets " << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" - << ifBeam_ << " zFront " << zFrontEE_ << ":" << zFrontFH_ << ":" - << zFrontBH_ << " IdBeam " << idBeams_.size() << ":"; - for (auto id : idBeams_) std::cout << " " << id; - std::cout << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: SimHits = " << doSimHits_ + << " Digis = " << doDigis_ << ":" << sampleIndex_ + << " RecHits = " << doRecHits_ << " useDets " + << ifEE_ << ":" << ifFH_ << ":" << ifBH_ << ":" + << ifBeam_ << " zFront " << zFrontEE_ << ":" + << zFrontFH_ << ":" << zFrontBH_ << " IdBeam " + << idBeams_.size() << ":"; + for (unsigned int k=0; k(tmp0); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: GeneratorSource = " << tmp0; #endif std::string tmp1 = iConfig.getParameter("CaloHitSrcEE"); tok_hitsEE_ = consumes(edm::InputTag("g4SimHits",tmp1)); @@ -174,8 +177,9 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { tok_hitrEE_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifEE_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorEE_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorEE_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcFH"); @@ -186,8 +190,9 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { tok_hitrFH_ = consumes(tmp3); #ifdef EDM_ML_DEBUG if (ifFH_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorFH_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorFH_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcBH"); @@ -212,16 +217,17 @@ HGCalTBAnalyzer::HGCalTBAnalyzer(const edm::ParameterSet& iConfig) { #ifdef EDM_ML_DEBUG if (ifBH_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorBH_ << " with tags " - << tmp1 << ", " << tmp2 << ", " << tmp3 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " << detectorBH_ + << " with tags " << tmp1 << ", " << tmp2 << ", " + << tmp3; } #endif tmp1 = iConfig.getParameter("CaloHitSrcBeam"); tok_hitsBeam_= consumes(edm::InputTag("g4SimHits",tmp1)); #ifdef EDM_ML_DEBUG if (ifBeam_) { - std::cout << "HGCalTBAnalyzer:: Detector " << detectorBeam_ - << " with tags " << tmp1 << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer:: Detector " + << detectorBeam_ << " with tags " << tmp1; } #endif } @@ -418,8 +424,9 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer::" << detectorEE_ << " defined with " - << hgcons_[0]->layers(false) << " layers" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorEE_ + << " defined with " << hgcons_[0]->layers(false) + << " layers"; #endif } else { hgcons_[0] = nullptr; @@ -450,8 +457,9 @@ void HGCalTBAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup) { } } #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBAnalyzer::" << detectorFH_ << " defined with " - << hgcons_[1]->layers(false) << " layers" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::" << detectorFH_ + << " defined with " << hgcons_[1]->layers(false) + << " layers"; #endif } else { hgcons_[1] = nullptr; @@ -496,9 +504,10 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, p != myGenEvent->particles_end(); ++p, ++k) { if (k == 0) hBeam_->Fill((*p)->momentum().rho()); #ifdef EDM_ML_DEBUG - std::cout << "Particle[" << k << "] with p " << (*p)->momentum().rho() - << " theta " << (*p)->momentum().theta() << " phi " - << (*p)->momentum().phi() << std::endl; + edm::LogVerbatim("HGCSim") << "Particle[" << k << "] with p " + << (*p)->momentum().rho() << " theta " + << (*p)->momentum().theta() << " phi " + << (*p)->momentum().phi(); #endif } } @@ -527,8 +536,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorEE_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorEE_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -536,8 +546,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(0, caloHits, zFrontEE_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorEE_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorEE_ << " !!!"; #endif } } @@ -547,8 +557,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorFH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorFH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -556,8 +567,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(1, caloHits, zFrontFH_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorFH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorFH_ << " !!!"; #endif } } @@ -567,8 +578,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsBH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorBH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -576,8 +588,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(2, caloHits, zFrontBH_); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorBH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorBH_ << " !!!"; #endif } } @@ -586,8 +598,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitsBeam_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "PcalohitContainer for " << detectorBeam_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "PcalohitContainer for " << detectorBeam_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif caloHits.clear(); caloHits.insert(caloHits.end(), theCaloHitContainers->begin(), @@ -595,8 +608,8 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, analyzeSimHits(3, caloHits, 0.0); } else { #ifdef EDM_ML_DEBUG - std::cout << "PCaloHitContainer does not exist for " << detectorBeam_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "PCaloHitContainer does not exist for " + << detectorBeam_ << " !!!"; #endif } } @@ -642,8 +655,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_digiEE_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCDigiCintainer for " << detectorEE_ << " with " - << theDigiContainers->size() << " element(s)" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCDigiCintainer for " << detectorEE_ + << " with " << theDigiContainers->size() + << " element(s)"; #endif for (auto it : *theDigiContainers) { HGCalDetId detId = (it.id()); @@ -658,8 +672,9 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_digiFH_, theDigiContainers); if (theDigiContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCDigiContainer for " << detectorFH_ << " with " - << theDigiContainers->size() << " element(s)" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCDigiContainer for " << detectorFH_ + << " with " << theDigiContainers->size() + << " element(s)"; #endif for (auto it : *theDigiContainers) { HGCalDetId detId = (it.id()); @@ -678,14 +693,15 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitrEE_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection for " << detectorEE_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorEE_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif analyzeRecHits(0, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection does not exist for " << detectorEE_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorEE_ << " !!!"; #endif } } @@ -693,14 +709,15 @@ void HGCalTBAnalyzer::analyze(const edm::Event& iEvent, iEvent.getByToken(tok_hitrFH_, theCaloHitContainers); if (theCaloHitContainers.isValid()) { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection for " << detectorFH_ << " has " - << theCaloHitContainers->size() << " hits" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection for " << detectorFH_ + << " has " << theCaloHitContainers->size() + << " hits"; #endif analyzeRecHits(1, theCaloHitContainers); } else { #ifdef EDM_ML_DEBUG - std::cout << "HGCRecHitCollection does not exist for " << detectorFH_ - << " !!!" << std::endl; + edm::LogVerbatim("HGCSim") << "HGCRecHitCollection does not exist for " + << detectorFH_ << " !!!"; #endif }//else }//if (ifFH_) @@ -742,10 +759,11 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, idx = sector*1000+cell; } #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Hit[" << i << "] Id " << subdet << ":" << zside << ":" - << layer << ":" << sector << ":" << subsector << ":" << cell - << ":" << depth << " Energy " << energy << " Time " << time - << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Hit[" << i << "] Id " << subdet + << ":" << zside << ":" << layer << ":" + << sector << ":" << subsector << ":" << cell + << ":" << depth << " Energy " << energy + << " Time " << time; #endif if (map_hits.count(id) != 0) { map_hits[id] += energy; @@ -794,8 +812,8 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, if (type < 2) zp = hgcons_[type]->waferZ(layer+1,false); else if (type == 2) zp = AHCalDetId((itr.second).first).getZ(); #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer+1 << " Z " << zp << ":" << zp-zFront - << " E " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " Z " << zp + << ":" << zp-zFront << " E " << energy; #endif if (type < 3) { hSimHitLng_[type]->Fill(zp-zFront,energy); @@ -830,7 +848,7 @@ void HGCalTBAnalyzer::analyzeSimHits (int type, std::vector& hits, int layer = itr.first - 1; double energy = itr.second; #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer+1 << " " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer+1 << " " << energy; #endif hSimHitLng1_[type]->Fill(layer+1,energy); if (type == 0) { @@ -894,11 +912,12 @@ void HGCalTBAnalyzer::analyzeSimTracks(edm::Handle const int vertIndex(-1); for (auto simTrkItr : *SimTk) { #ifdef EDM_ML_DEBUG - std::cout << "Track " << simTrkItr.trackId() << " Vertex " - << simTrkItr.vertIndex() << " Type " << simTrkItr.type() - << " Charge " << simTrkItr.charge() << " momentum " - << simTrkItr.momentum() << " " << simTrkItr.momentum().P() - << std::endl; + edm::LogVerbatim("HGCSim") << "Track " << simTrkItr.trackId() << " Vertex " + << simTrkItr.vertIndex() << " Type " + << simTrkItr.type() << " Charge " + << simTrkItr.charge() << " momentum " + << simTrkItr.momentum() << " " + << simTrkItr.momentum().P(); #endif if (vertIndex == -1) { vertIndex = simTrkItr.vertIndex(); @@ -909,8 +928,8 @@ void HGCalTBAnalyzer::analyzeSimTracks(edm::Handle const edm::SimVertexContainer::const_iterator simVtxItr= SimVtx->begin(); for (int iv=0; ivposition() << std::endl; + edm::LogVerbatim("HGCSim") << "Vertex " << vertIndex << " position " + << simVtxItr->position(); #endif xBeam_ = simVtxItr->position().X(); yBeam_ = simVtxItr->position().Y(); @@ -954,8 +973,9 @@ void HGCalTBAnalyzer::analyzeRecHits (int type, map_hitCell[cell] = std::pair(detId,energy); } #ifdef EDM_ML_DEBUG - std::cout << "RecHit: " << layer << " " << global.x() << " " << global.y() - << " " << global.z() << " " << energy << std::endl; + edm::LogVerbatim("HGCSim") << "RecHit: " << layer << " " << global.x() + << " " << global.y() << " " << global.z() + << " " << energy; #endif } @@ -964,8 +984,8 @@ void HGCalTBAnalyzer::analyzeRecHits (int type, double energy = itr.second; double zp = hgcons_[type]->waferZ(layer,true); #ifdef EDM_ML_DEBUG - std::cout << "SimHit:Layer " << layer << " " << zp << " " << energy - << std::endl; + edm::LogVerbatim("HGCSim") << "SimHit:Layer " << layer << " " << zp + << " " << energy; #endif hRecHitLng_[type]->Fill(zp,energy); hRecHitLng1_[type]->Fill(layer,energy); @@ -987,9 +1007,9 @@ void HGCalTBAnalyzer::analyzePassiveHits (edm::Handlec unsigned int id = v.id(); #ifdef EDM_ML_DEBUG double time = v.time(); - std::cout << "HGCalTBAnalyzer::analyzePassiveHits:Energy:Time:Name:Id : " - << energy << ":" << time << ":" << name << ":" << id - << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBAnalyzer::analyzePassiveHits:Energy:" + << "Time:Name:Id : " << energy << ":" << time + << ":" << name << ":" << id; #endif if (subdet==1) { diff --git a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc index 96152541b763d..86ea0f57a0b8c 100644 --- a/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBCheckGunPosition.cc @@ -24,6 +24,7 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -32,6 +33,7 @@ #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" #include +//#define EDM_ML_DEBUG // // class declaration @@ -99,7 +101,7 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, iEvent.getByToken(hepMCproductLabel_, hepmc); #ifdef DebugLog if (verbosity_) - std::cout << "isHandle valid: " << isHandle valid << std::endl; + edm::LogVerbatim("HGCSim") << "isHandle valid: " << isHandle valid; #endif double x(0), y(0); @@ -108,7 +110,7 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, #ifdef DebugLog if (verbosity_) - std::cout << "vertex " << Evt->vertices_size() << std::endl; + edm::LogVerbatim("HGCSim") << "vertex " << Evt->vertices_size(); #endif for (HepMC::GenEvent::vertex_const_iterator p = Evt->vertices_begin(); p != Evt->vertices_end(); ++p) { @@ -117,10 +119,10 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, #ifdef DebugLog z = (*p)->position().z()/10.; // in cm if (verbosity_) - std::cout << " x: " << (*p)->position().x() << ":" << x - << " y: " << (*p)->position().y() << ":" << y - << " z: " << (*p)->position().z() << ":" << z - << std::endl; + edm::LogVerbatim("HGCSim") << " x: " << (*p)->position().x() << ":" + << x << " y: " << (*p)->position().y() + <<":" << y << " z: " << (*p)->position().z() + << ":" << z; #endif } }//if (genEventInfoHandle.isValid()) @@ -144,7 +146,8 @@ bool HGCalTBCheckGunPostion::filter(edm::Event& iEvent, } #ifdef DebugLog - if (verbosity_) std::cout << "Selection Flag " << flag << std::endl; + if (verbosity_) + edm::LogVerbatim("HGCSim") << "Selection Flag " << flag; #endif return flag; } diff --git a/SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc similarity index 63% rename from SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc rename to SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc index 6ee86621525e3..1cbf82d0ccec5 100644 --- a/SimG4CMS/HGCalTestBeam/src/HGCalTBMB.cc +++ b/SimG4CMS/HGCalTestBeam/plugins/HGCalTBMB.cc @@ -1,10 +1,11 @@ -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h" - -#include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/Exception.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "SimG4Core/Watcher/interface/SimWatcher.h" +#include "SimG4Core/Notification/interface/Observer.h" #include "SimG4Core/Notification/interface/BeginOfTrack.h" #include "SimG4Core/Notification/interface/EndOfTrack.h" @@ -12,10 +13,44 @@ #include "G4Step.hh" #include "G4Track.hh" +#include + #include +#include +#include //#define EDM_ML_DEBUG +class HGCalTBMB : public SimWatcher, + public Observer, + public Observer, + public Observer { + +public: + + HGCalTBMB(const edm::ParameterSet&); + ~HGCalTBMB() override; + +private: + + HGCalTBMB(const HGCalTBMB&) = delete; // stop default + const HGCalTBMB& operator=(const HGCalTBMB&) = delete; // ... + + void update(const BeginOfTrack*) override; + void update(const G4Step*) override; + void update(const EndOfTrack*) override; + + bool stopAfter(const G4Step*); + int findVolume(const G4VTouchable* touch, bool stop) const; + + std::vector listNames_; + std::string stopName_; + double stopZ_; + unsigned int nList_; + std::vector radLen_, intLen_, stepLen_; + std::vector me100_, me200_, me300_; +}; + HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { edm::ParameterSet m_p = p.getParameter("HGCalTBMB"); @@ -23,11 +58,12 @@ HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { stopName_ = m_p.getParameter("StopName"); stopZ_ = m_p.getParameter("MaximumZ"); nList_ = listNames_.size(); - edm::LogInfo("HGCSim") << "HGCalTBMB initialized for " << nList_ <<" volumes\n"; + edm::LogVerbatim("HGCSim") << "HGCalTBMB initialized for " << nList_ + << " volumes"; for (unsigned int k=0; k tfile; if ( !tfile.isAvailable() ) @@ -53,12 +89,11 @@ HGCalTBMB::HGCalTBMB(const edm::ParameterSet& p) { hist->Sumw2(true); me300_.push_back(hist); } - edm::LogInfo("HGCSim") << "HGCalTBMB: Booking user histos done ==="; + edm::LogVerbatim("HGCSim") << "HGCalTBMB: Booking user histos done ==="; } HGCalTBMB::~HGCalTBMB() { } - void HGCalTBMB::update(const BeginOfTrack* trk) { radLen_ = std::vector(nList_+1,0); @@ -70,9 +105,10 @@ void HGCalTBMB::update(const BeginOfTrack* trk) { const G4ThreeVector& mom = aTrack->GetMomentum() ; double theEnergy = aTrack->GetTotalEnergy(); int theID = (int)(aTrack->GetDefinition()->GetPDGEncoding()); - std::cout << "MaterialBudgetHcalHistos: Track " << aTrack->GetTrackID() - << " Code " << theID << " Energy " <GetTrackID() << " Code " << theID + << " Energy " << theEnergy/CLHEP::GeV + << " GeV; Momentum " << mom ; #endif } @@ -95,10 +131,10 @@ void HGCalTBMB::update(const G4Step* aStep) { radLen_[nList_] += (step/radl); intLen_[nList_] += (step/intl); #ifdef EDM_ML_DEBUG - std::cout << "HGCalTBMB::Step in " - << touch->GetVolume(0)->GetLogicalVolume()->GetName() - << " Index " << indx <<" Step " << step << " RadL " << step/radl - << " IntL " << step/intl << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBMB::Step in " + << touch->GetVolume(0)->GetLogicalVolume()->GetName() + << " Index " << indx <<" Step " << step + << " RadL " << step/radl << " IntL " << step/intl; #endif if (stopAfter(aStep)) { @@ -116,9 +152,9 @@ void HGCalTBMB::update(const EndOfTrack* trk) { #ifdef EDM_ML_DEBUG std::string name("Total"); if (ii < nList_) name = listNames_[ii]; - std::cout << "HGCalTBMB::Volume[" << ii << "]: " << name << " == Step " - << stepLen_[ii] << " RadL " << radLen_[ii] << " IntL " - << intLen_[ii] << std::endl; + edm::LogVerbatim("HGCSim") << "HGCalTBMB::Volume[" << ii << "]: " << name + << " == Step " << stepLen_[ii] << " RadL " + << radLen_[ii] << " IntL " << intLen_[ii]; #endif } } @@ -134,8 +170,9 @@ bool HGCalTBMB::stopAfter(const G4Step* aStep) { if ((findVolume(touch,true) == 0) || (zz > stopZ_)) flag = true; #ifdef EDM_ML_DEBUG - std::cout << " HGCalTBMB::Name " << touch->GetVolume(0)->GetName() << " z " - << zz << " Flag" << flag << std::endl; + edm::LogVerbatim("HGCSim") << " HGCalTBMB::Name " + << touch->GetVolume(0)->GetName() << " z " + << zz << " Flag" << flag; #endif return flag; } @@ -160,3 +197,9 @@ int HGCalTBMB::findVolume(const G4VTouchable* touch, bool stop) const { return ivol; } +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" + +DEFINE_SIMWATCHER (HGCalTBMB); + diff --git a/SimG4CMS/HGCalTestBeam/plugins/module.cc b/SimG4CMS/HGCalTestBeam/plugins/module.cc deleted file mode 100644 index 9c0b6e7b10061..0000000000000 --- a/SimG4CMS/HGCalTestBeam/plugins/module.cc +++ /dev/null @@ -1,15 +0,0 @@ -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTB16SD01.h" -#include "SimG4CMS/HGCalTestBeam/interface/AHCalSD.h" -#include "SimG4CMS/HGCalTestBeam/interface/HGCalTBMB.h" -#include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h" -#include "SimG4Core/Watcher/interface/SimWatcherFactory.h" -#include "FWCore/PluginManager/interface/ModuleDef.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -typedef HGCalTB16SD01 HGCalTB1601SensitiveDetector; -DEFINE_SENSITIVEDETECTOR(HGCalTB1601SensitiveDetector); -typedef AHCalSD AHcalSensitiveDetector; -DEFINE_SENSITIVEDETECTOR(AHcalSensitiveDetector); - -DEFINE_SIMWATCHER (HGCalTBMB); - diff --git a/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py b/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py index 35efb3b970e68..77bd2dbe76808 100644 --- a/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py +++ b/SimG4CMS/HGCalTestBeam/python/hgcalTBMBCERN_cfi.py @@ -2,20 +2,24 @@ from SimG4Core.Configuration.SimG4Core_cff import * g4SimHits.Watchers = cms.VPSet(cms.PSet( - HGCalTBMB = cms.PSet( - DetectorNames = cms.vstring( - 'HGCalBeamWChamb', - 'HGCalBeamS1', - 'HGCalBeamS2', - 'HGCalBeamS3', - 'HGCalBeamS4', - 'HGCalBeamHaloCounter', - 'HGCalBeamCK3', - 'HGCalBeamMuonCounter', - ), - MaximumZ = cms.double(9500.), - StopName = cms.string("HGCal"), - ), - type = cms.string('HGCalTBMB') - ) - ) + HGCalTBMB = cms.PSet( + DetectorNames = cms.vstring( + 'HGCalBeamWChamb', + 'HGCalBeamS1', + 'HGCalBeamS2', + 'HGCalBeamS3', + 'HGCalBeamS4', + 'HGCalBeamHaloCounter', + 'HGCalBeamCK3', + 'HGCalBeamMuonCounter', + 'HGCalEE', + 'HGCalHE', + 'HGCalAH' + ), + #MaximumZ = cms.double(9500.), + MaximumZ = cms.double(950000.), + #StopName = cms.string("HGCal"), + StopName = cms.string("Junk"), + ), + type = cms.string('HGCalTBMB') +)) diff --git a/SimG4CMS/HGCalTestBeam/test/HGCalTBCERN181Oct_cfg.py b/SimG4CMS/HGCalTestBeam/test/HGCalTBCERN181Oct_cfg.py index dfe6617db91c7..dfa7b80292686 100644 --- a/SimG4CMS/HGCalTestBeam/test/HGCalTBCERN181Oct_cfg.py +++ b/SimG4CMS/HGCalTestBeam/test/HGCalTBCERN181Oct_cfg.py @@ -25,6 +25,8 @@ ) if 'MessageLogger' in process.__dict__: + process.MessageLogger.categories.append('HGCalGeom') + process.MessageLogger.categories.append('SimG4CoreGeometry') process.MessageLogger.categories.append('HGCSim') process.MessageLogger.categories.append('HcalSim') process.MessageLogger.categories.append('HcalTB06BeamSD') diff --git a/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py b/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py index 0b528af0ef2fd..057be620eda00 100644 --- a/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py +++ b/SimG4CMS/HGCalTestBeam/test/HGCalTBGenSimCERNMB_cfg.py @@ -1,18 +1,21 @@ import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras -process = cms.Process('SIM') +process = cms.Process('SIM',eras.Phase2) # import of standard configurations process.load('Configuration.StandardSequences.Services_cff') process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('SimG4CMS.HGCalTestBeam.HGCalTB161Module8XML_cfi') +process.load('SimG4CMS.HGCalTestBeam.HGCalTB181Oct1XML_cfi') +#process.load('SimG4CMS.HGCalTestBeam.HGCalTB161Module8XML_cfi') process.load('Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi') process.load('Geometry.HGCalCommonData.hgcalParametersInitialization_cfi') process.load('Configuration.StandardSequences.MagneticField_0T_cff') process.load('Configuration.StandardSequences.Generator_cff') process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi') +#process.load('IOMC.EventVertexGenerators.VtxSmearedGauss_cfi') process.load('GeneratorInterface.Core.genFilterSummary_cff') process.load('Configuration.StandardSequences.SimIdeal_cff') process.load('Configuration.StandardSequences.EndOfProcess_cff') @@ -25,24 +28,15 @@ input = cms.untracked.int32(100) ) -process.MessageLogger = cms.Service("MessageLogger", - cout = cms.untracked.PSet( - default = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - HGCSim = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - ), - categories = cms.untracked.vstring('HGCSim'), - destinations = cms.untracked.vstring('cout','cerr') -) +if 'MessageLogger' in process.__dict__: + process.MessageLogger.categories.append('HGCalGeom') + process.MessageLogger.categories.append('HGCSim') + # Input source process.source = cms.Source("EmptySource") process.options = cms.untracked.PSet( - ) # Production Info @@ -81,18 +75,23 @@ process.generator = cms.EDProducer("FlatRandomEThetaGunProducer", AddAntiParticle = cms.bool(False), PGunParameters = cms.PSet( - MinE = cms.double(9.99), - MaxE = cms.double(10.01), + MinE = cms.double(99.99), + MaxE = cms.double(100.01), MinTheta = cms.double(0.0), MaxTheta = cms.double(0.0), MinPhi = cms.double(-3.14159265359), MaxPhi = cms.double(3.14159265359), - PartID = cms.vint32(14) +# MinTheta = cms.double(.011837), +# MaxTheta = cms.double(.011837), +# MinPhi = cms.double(3.649887), +# MaxPhi = cms.double(3.649887), + PartID = cms.vint32(13) ), Verbosity = cms.untracked.int32(0), firstRun = cms.untracked.uint32(1), psethack = cms.string('single muon E 100') ) + process.VtxSmeared.MinZ = -800.0 process.VtxSmeared.MaxZ = -800.0 process.VtxSmeared.MinX = 0 @@ -102,7 +101,6 @@ process.HGCalTBAnalyzer.DoDigis = False process.HGCalTBAnalyzer.DoRecHits = False - # Path and EndPath definitions process.generation_step = cms.Path(process.pgen) process.simulation_step = cms.Path(process.psim) @@ -112,7 +110,14 @@ process.RAWSIMoutput_step = cms.EndPath(process.RAWSIMoutput) # Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.analysis_step,process.endjob_step,process.RAWSIMoutput_step) +process.schedule = cms.Schedule( + process.generation_step, + process.genfiltersummary_step, + process.simulation_step, + process.analysis_step, + process.endjob_step, + process.RAWSIMoutput_step +) # filter all path with the production filter sequence for path in process.paths: diff --git a/SimG4Core/CustomPhysics/src/CMSDarkPairProduction.cc b/SimG4Core/CustomPhysics/src/CMSDarkPairProduction.cc index 27b2cf9d72a11..455dd2abd5cbd 100644 --- a/SimG4Core/CustomPhysics/src/CMSDarkPairProduction.cc +++ b/SimG4Core/CustomPhysics/src/CMSDarkPairProduction.cc @@ -12,9 +12,6 @@ using namespace std; -static const G4double xsfactor = - 4*CLHEP::fine_structure_const*CLHEP::classic_electr_radius*CLHEP::classic_electr_radius; - CMSDarkPairProduction::CMSDarkPairProduction(const G4ParticleDefinition* p,G4double df, const G4String& nam) : G4PairProductionRelModel(p,nam), dark_factor(df) {} diff --git a/SimG4Core/PrintGeomInfo/test/python/g4OverlapCheckHGCal_cfg.py b/SimG4Core/PrintGeomInfo/test/python/g4OverlapCheckHGCal_cfg.py new file mode 100644 index 0000000000000..ef644c66109f3 --- /dev/null +++ b/SimG4Core/PrintGeomInfo/test/python/g4OverlapCheckHGCal_cfg.py @@ -0,0 +1,37 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("G4PrintGeometry") + +#process.load('Configuration.Geometry.GeometryExtended2017_cff') +process.load('Geometry.HGCalCommonData.testHGCalV10XML_cfi') + +from SimG4Core.PrintGeomInfo.g4TestGeometry_cfi import * +process = checkOverlap(process) + +process.MessageLogger.destinations = cms.untracked.vstring("HGCal.overlaps") +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HGCalGeom') + process.MessageLogger.categories.append('SimG4CoreGeometry') + +# enable Geant4 overlap check +process.g4SimHits.CheckOverlap = True + +# Geant4 overlap check conditions +process.g4SimHits.G4CheckOverlap.Tolerance = cms.untracked.double(0.0) +process.g4SimHits.G4CheckOverlap.Resolution = cms.untracked.int32(10000) +# tells if NodeName is G4Region or G4PhysicalVolume +process.g4SimHits.G4CheckOverlap.RegionFlag = cms.untracked.bool(False) +# list of names +process.g4SimHits.G4CheckOverlap.NodeNames = cms.vstring('CMSE') +# enable dump gdml file +process.g4SimHits.G4CheckOverlap.gdmlFlag = cms.untracked.bool(False) +# if defined a G4PhysicsVolume info is printed +process.g4SimHits.G4CheckOverlap.PVname = '' +# if defined a list of daughter volumes is printed +process.g4SimHits.G4CheckOverlap.LVname = '' + +# extra output files, created if a name is not empty +process.g4SimHits.FileNameField = '' +process.g4SimHits.FileNameGDML = '' +process.g4SimHits.FileNameRegions = '' +# diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index a54b8f6fa2a29..9eaa7bbe3b2dc 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -36,7 +36,7 @@ def _modifyPixelDigitizerForPhase1Pixel( digitizer ) : digitizer.ElectronsPerVcal_Offset = cms.double(-60) # L2-4: -60 +- 130 digitizer.ElectronsPerVcal_L1_Offset = cms.double(-670) # L1: -670 +- 220 digitizer.UseReweighting = cms.bool(True) - + digitizer.KillBadFEDChannels = cms.bool(True) SiPixelSimBlock = cms.PSet( SiPixelQualityLabel = cms.string(''), diff --git a/SimTracker/SiStripDigitizer/plugins/SiTrivialInduceChargeOnStrips.cc b/SimTracker/SiStripDigitizer/plugins/SiTrivialInduceChargeOnStrips.cc index d986afe3cd186..bdf41a7638e44 100644 --- a/SimTracker/SiStripDigitizer/plugins/SiTrivialInduceChargeOnStrips.cc +++ b/SimTracker/SiStripDigitizer/plugins/SiTrivialInduceChargeOnStrips.cc @@ -71,9 +71,6 @@ namespace { return signalCoupling; } - inline unsigned int indexOf(const std::string& t) { return std::find( type, type + Ntypes, t) - type;} - - inline unsigned int typeOf(const StripGeomDetUnit& det, const TrackerTopology *tTopo) { DetId id = det.geographicalId(); switch (det.specificType().subDetector()) { diff --git a/SimTracker/TrackerMaterialAnalysis/plugins/ListGroups.cc b/SimTracker/TrackerMaterialAnalysis/plugins/ListGroups.cc index b692e83644b50..dfcd20d40ef53 100644 --- a/SimTracker/TrackerMaterialAnalysis/plugins/ListGroups.cc +++ b/SimTracker/TrackerMaterialAnalysis/plugins/ListGroups.cc @@ -76,12 +76,6 @@ std::string dddGetString(const std::string & s, DDFilteredView const & view) { return std::string(); } -static inline -std::ostream & operator<<(std::ostream & out, const math::XYZVector & v) { - out << std::fixed << std::setprecision(3); - return out << "(" << v.rho() << ", " << v.z() << ", " << v.phi() << ")"; -} - class ListGroups : public edm::one::EDAnalyzer<> { public: diff --git a/TrackPropagation/SteppingHelixPropagator/src/SteppingHelixPropagator.cc b/TrackPropagation/SteppingHelixPropagator/src/SteppingHelixPropagator.cc index cda79892ac24c..5cdd1e8fe9298 100644 --- a/TrackPropagation/SteppingHelixPropagator/src/SteppingHelixPropagator.cc +++ b/TrackPropagation/SteppingHelixPropagator/src/SteppingHelixPropagator.cc @@ -1977,11 +1977,12 @@ SteppingHelixPropagator::refToMagVolume(const SteppingHelixPropagator::StateInfo const Surface* cPlane = nullptr; //only need to know the loc->glob transform const Cylinder* cCyl = nullptr; const Cone* cCone = nullptr; - if (typeid(cVolFaces[iFace].surface()) == typeid(const Plane&)){ + auto& iSurface = cVolFaces[iFace].surface(); + if (typeid(iSurface) == typeid(const Plane&)){ cPlane = &cVolFaces[iFace].surface(); - } else if (typeid(cVolFaces[iFace].surface()) == typeid(const Cylinder&)){ + } else if (typeid(iSurface) == typeid(const Cylinder&)){ cCyl = dynamic_cast(&cVolFaces[iFace].surface()); - } else if (typeid(cVolFaces[iFace].surface()) == typeid(const Cone&)){ + } else if (typeid(iSurface) == typeid(const Cone&)){ cCone = dynamic_cast(&cVolFaces[iFace].surface()); } else { edm::LogWarning(metname)< TrackTransformerForCosmicMuons::transform(const reco::Track& Trajectory const & trajectoryBW = trajectories.front(); - vector && trajectoriesSM = smoother(up, quadrant, sumdy)->trajectories(trajectoryBW); + vector trajectoriesSM = smoother(up, quadrant, sumdy)->trajectories(trajectoryBW); if(trajectoriesSM.empty()){ LogTrace(metname)<<"No Track smoothed!"<(); } return trajectoriesSM; diff --git a/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py b/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py index 57fa462218485..306370bdf663a 100755 --- a/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py +++ b/Utilities/ReleaseScripts/python/cmsCodeRules/showPage.py @@ -152,7 +152,7 @@ def createLogFiles(rulesResult, logsDir, ib): for path, lineNumbers in packageResult: for line in lineNumbers: directory = join(package, path) - file.write('%s:%s\n'%(directory, ib, numberConverter(line), directory, line)) + file.write('%s:%s\n'%(directory, ib, numberConverter(line), directory, line)) file.write("
") file.write('\n') file.close() diff --git a/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules b/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules index 84cab1fd38e13..f401c6294a12a 100644 --- a/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules +++ b/Utilities/ReleaseScripts/scripts/CMSSWReleaseDependency.rules @@ -133,7 +133,7 @@ ElectroWeakAnalysis/Utilities/.* : f77compiler #FastSim exception FastSimulation/.* : FastSimulation/.* -GeneratorInterface/GenFilters/.* : FastSimulation/BaseParticlePropagator,FastSimulation/Particle +GeneratorInterface/GenFilters/.* : FastSimulation/Particle RecoParticleFlow/PF.* : FastSimulation/.*,GeneratorInterface/.* #################################################### diff --git a/Utilities/ReleaseScripts/scripts/createBuildFile.conf b/Utilities/ReleaseScripts/scripts/createBuildFile.conf index dabcc516a3f5a..26dd5713ff9ca 100644 --- a/Utilities/ReleaseScripts/scripts/createBuildFile.conf +++ b/Utilities/ReleaseScripts/scripts/createBuildFile.conf @@ -29,7 +29,6 @@ DATA:EXTRA_TOOL_INFO:boost:FILES_PACKAGE_MAP:^boost\/python(\/|\.).+:boost_pytho DATA:REMOVE_FLAGS:PRODUCTS:^AlignmentCocoaApplication$:EDM_PLUGIN:1 DATA:REMOVE_FLAGS:PRODUCTS:^AlignmentOptAlignCSV2DB$:EDM_PLUGIN:1 -DATA:REMOVE_FLAGS:PRODUCTS:^RecoParticleFlowPFClusterShapeProducer$:EDM_PLUGIN:1 DATA:REMOVE_FLAGS:PRODUCTS:^CalibTrackerSiPixelTools$:EDM_PLUGIN:1 DATA:REMOVE_FLAGS:PRODUCTS:^CondToolsSiPixel$:EDM_PLUGIN:1 DATA:REMOVE_TOOLS:PRODUCTS:^UtilitiesRFIOAdaptorPlugin$:castor:1 diff --git a/Utilities/ReleaseScripts/scripts/duplicateReflexLibrarySearch.py b/Utilities/ReleaseScripts/scripts/duplicateReflexLibrarySearch.py index 660f3713d217c..93debc5b35cf5 100755 --- a/Utilities/ReleaseScripts/scripts/duplicateReflexLibrarySearch.py +++ b/Utilities/ReleaseScripts/scripts/duplicateReflexLibrarySearch.py @@ -35,15 +35,17 @@ equivDict = \ [ {'TrajectoryState' : ['TrajectoryStateOnSurface']}, - {'TrackTriggerAssociation' : ['(TTClusterAssociationMap|TTStubAssociationMap|TTTrackAssociationMap).*Phase2TrackerDigi', - '(TTStub|TTCluster|TTTrack).*Phase2TrackerDigi']}, + {'TrackTriggerAssociation' : ['(TTClusterAssociationMap|TTStubAssociationMap|TTTrackAssociationMap|TrackingParticle).*Phase2TrackerDigi', + '(TTStub|TTCluster|TTTrack).*Phase2TrackerDigi.*TrackingParticle']}, + {'L1TrackTrigger' : ['(TTStub|TTCluster|TTTrack).*Phase2TrackerDigi']}, {'L1TCalorimeter' : ['l1t::CaloTower.*']}, {'GsfTracking' : ['reco::GsfTrack(Collection|).*(MomentumConstraint|VertexConstraint)', 'Trajectory.*reco::GsfTrack']}, {'ParallelAnalysis' : ['examples::TrackAnalysisAlgorithm']}, - {'PatCandidates' : ['pat::PATObject','pat::Lepton']}, + {'PatCandidates' : ['pat::PATObject','pat::Lepton', 'reco::RecoCandidate','pat::[A-Za-z]+Ref(Vector|)', 'pat::UserHolder']}, {'BTauReco' : ['reco::.*SoftLeptonTagInfo', 'reco::SoftLeptonProperties','reco::SecondaryVertexTagInfo','reco::IPTagInfo','reco::TemplatedSecondaryVertexTagInfo', 'reco::CATopJetProperties','reco::HTTTopJetProperties']}, {'CastorReco' : ['reco::CastorJet']}, {'JetMatching' : ['reco::JetFlavourInfo', 'reco::JetFlavour','reco::MatchedPartons']}, + {'RecoCandidate' : ['reco::Candidate','edm::Wrapper.+edm::AssociationMap.+TrackingParticle']}, {'TrackingAnalysis' : ['TrackingParticle']}, {'Egamma' : ['reco::ElectronID']}, {'TopObjects' : ['reco::CATopJetProperties']}, @@ -68,11 +70,9 @@ {'ParticleFlowReco' : ['reco::RecoPFClusterRefCandidateRef.*']}, {'ParticleFlowCandidate' : ['reco::PFCandidateRef','reco::PFCandidateFwdRef','reco::PFCandidate']}, {'PhysicsToolsObjects' : ['PhysicsTools::Calibration']}, - {'RecoCandidate' : ['reco::Candidate']}, {'TrackReco' : ['reco::Track','reco::TrackRef']}, {'VertexReco' : ['reco::Vertex']}, {'TFWLiteSelectorTest' : ['tfwliteselectortest']}, - {'PatCandidates' : ['reco::RecoCandidate','pat::[A-Za-z]+Ref(Vector|)']}, {'TauReco' : ['reco::PFJetRef']}, {'JetReco' : ['reco::.*Jet','reco::.*Jet(Collection|Ref)']}, {'HGCDigi' : ['HGCSample']}, diff --git a/Utilities/ReleaseScripts/scripts/git-publish b/Utilities/ReleaseScripts/scripts/git-publish index b737f985cffc4..ece144397f1fa 100755 --- a/Utilities/ReleaseScripts/scripts/git-publish +++ b/Utilities/ReleaseScripts/scripts/git-publish @@ -192,7 +192,7 @@ CMSSW_CATEGORIES={"Operations": ["Configuration/Applications", "Utilities/StorageFactory", "Utilities/Testing", "Utilities/Timing", "Utilities/XrdAdaptor"], "Documentation": ["Documentation/CodingRules", "Documentation/PhysicsTools", "Documentation/ReferenceManualScripts"], - "Reconstruction": ["Configuration/EcalTB", "Configuration/JetMET", + "Reconstruction": ["Configuration/EcalTB", "Configuration/JetMET", "CommonTools/BaseParticlePropagator", "CommonTools/CandAlgos", "CommonTools/CandUtils", "CommonTools/Clustering1D", "CommonTools/ParticleFlow", "CommonTools/RecoAlgos", "CommonTools/Statistics", "CommonTools/TrackerMap", "CommonTools/TriggerUtils", "CommonTools/UtilAlgos", @@ -257,7 +257,7 @@ CMSSW_CATEGORIES={"Operations": ["Configuration/Applications", "RecoMuon/TrackingTools", "RecoMuon/TransientTrackingRecHit", "RecoParticleFlow/Benchmark", "RecoParticleFlow/Configuration", "RecoParticleFlow/PFBlockProducer", "RecoParticleFlow/PFClusterProducer", - "RecoParticleFlow/PFClusterShapeProducer", "RecoParticleFlow/PFClusterTools", + "RecoParticleFlow/PFClusterTools", "RecoParticleFlow/PFProducer", "RecoParticleFlow/PFRootEvent", "RecoParticleFlow/PFSimProducer", "RecoParticleFlow/PFTracking", "RecoPixelVZero/PixelVZeroFinding", "RecoPixelVertexing/Configuration", @@ -450,7 +450,7 @@ CMSSW_CATEGORIES={"Operations": ["Configuration/Applications", "QCDAnalysis/Skimming", "QCDAnalysis/UEAnalysis"], "Fast Simulation": ["FastSimDataFormats/External", "FastSimDataFormats/L1GlobalMuonTrigger", "FastSimDataFormats/NuclearInteractions", "FastSimDataFormats/PileUpEvents", - "FastSimulation/BaseParticlePropagator", "FastSimulation/CaloGeometryTools", + "CommonTools/BaseParticlePropagator", "FastSimulation/CaloGeometryTools", "FastSimulation/CaloHitMakers", "FastSimulation/CaloRecHitsProducer", "FastSimulation/CalorimeterProperties", "FastSimulation/Calorimetry", "FastSimulation/Configuration", "FastSimulation/EgammaElectronAlgos", diff --git a/Validation/CTPPS/plugins/BuildFile.xml b/Validation/CTPPS/plugins/BuildFile.xml new file mode 100644 index 0000000000000..7634b7d030415 --- /dev/null +++ b/Validation/CTPPS/plugins/BuildFile.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc new file mode 100644 index 0000000000000..ccd78ea2b6082 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSAcceptancePlotter.cc @@ -0,0 +1,310 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" + +#include +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSAcceptancePlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSAcceptancePlotter( const edm::ParameterSet& ); + + private: + void beginJob() override {} + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::EDGetTokenT tokenHepMC_; + edm::EDGetTokenT tokenTracks_; + + unsigned int rpId_45_N_, rpId_45_F_, rpId_56_N_, rpId_56_F_; + + std::string outputFile_; + + struct SingleArmPlots + { + std::unique_ptr h_xi_all, h_xi_acc; + SingleArmPlots() : + h_xi_all(new TH1D("", ";#xi", 100, 0., 0.25)), + h_xi_acc(new TH1D("", ";#xi", 100, 0., 0.25)) + {} + + void fill(double xi, bool acc) + { + h_xi_all->Fill(xi); + if (acc) + h_xi_acc->Fill(xi); + } + + void write() const + { + h_xi_all->Write("h_xi_all"); + h_xi_acc->Write("h_xi_acc"); + + auto h_xi_rat = std::make_unique(*h_xi_acc); + h_xi_rat->Divide(h_xi_all.get()); + h_xi_rat->Write("h_xi_rat"); + } + }; + + std::vector> singleArmConfigurations; + std::map, SingleArmPlots> singleArmPlots; + + struct DoubleArmPlots + { + std::unique_ptr h_m_all, h_m_acc; + std::unique_ptr h2_xi_45_vs_xi_56_all, h2_xi_45_vs_xi_56_acc; + std::unique_ptr h2_y_vs_m_all, h2_y_vs_m_acc; + + DoubleArmPlots() : + h_m_all(new TH1D("", ";m (GeV)", 100, 0., 2500.)), + h_m_acc(new TH1D("", ";m (GeV)", 100, 0., 2500.)), + h2_xi_45_vs_xi_56_all(new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)), + h2_xi_45_vs_xi_56_acc(new TH2D("", ";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)), + h2_y_vs_m_all(new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)), + h2_y_vs_m_acc(new TH2D("", ";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)) + {} + + void fill(double xi_45, double xi_56, bool acc) + { + const double p_nom = 6500.; + const double m = 2. * p_nom * sqrt(xi_45 * xi_56); + const double y = log(xi_45 / xi_56) / 2.; + + h_m_all->Fill(m); + h2_xi_45_vs_xi_56_all->Fill(xi_56, xi_45); + h2_y_vs_m_all->Fill(m, y); + + if (acc) { + h_m_acc->Fill(m); + h2_xi_45_vs_xi_56_acc->Fill(xi_56, xi_45); + h2_y_vs_m_acc->Fill(m, y); + } + } + + void write() const + { + h_m_all->Write("h_m_all"); + h_m_acc->Write("h_m_acc"); + + auto h_m_rat = std::make_unique(*h_m_acc); + h_m_rat->Divide(h_m_all.get()); + h_m_rat->Write("h_m_rat"); + + h2_xi_45_vs_xi_56_all->Write("h2_xi_45_vs_xi_56_all"); + h2_xi_45_vs_xi_56_acc->Write("h2_xi_45_vs_xi_56_acc"); + + auto h2_xi_45_vs_xi_56_rat = std::make_unique(*h2_xi_45_vs_xi_56_acc); + h2_xi_45_vs_xi_56_rat->Divide(h2_xi_45_vs_xi_56_all.get()); + h2_xi_45_vs_xi_56_rat->Write("h2_xi_45_vs_xi_56_rat"); + + h2_y_vs_m_all->Write("h2_y_vs_m_all"); + h2_y_vs_m_acc->Write("h2_y_vs_m_acc"); + + auto h2_y_vs_m_rat = std::make_unique(*h2_y_vs_m_acc); + h2_y_vs_m_rat->Divide(h2_y_vs_m_all.get()); + h2_y_vs_m_rat->Write("h2_y_vs_m_rat"); + } + }; + + std::vector> doubleArmConfigurations; + std::map, DoubleArmPlots> doubleArmPlots; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSAcceptancePlotter::CTPPSAcceptancePlotter(const edm::ParameterSet& iConfig) : + tokenHepMC_ (consumes(iConfig.getParameter("tagHepMC"))), + tokenTracks_(consumes(iConfig.getParameter("tagTracks"))), + rpId_45_N_ (iConfig.getParameter("rpId_45_N")), + rpId_45_F_ (iConfig.getParameter("rpId_45_F")), + rpId_56_N_ (iConfig.getParameter("rpId_56_N")), + rpId_56_F_ (iConfig.getParameter("rpId_56_F")), + outputFile_(iConfig.getParameter("outputFile")) +{ + singleArmConfigurations = { + { rpId_45_N_ }, + { rpId_45_F_ }, + { rpId_56_N_ }, + { rpId_56_F_ }, + { rpId_45_N_, rpId_45_F_ }, + { rpId_56_N_, rpId_56_F_ }, + }; + + doubleArmConfigurations = { + { rpId_45_N_, rpId_56_N_ }, + { rpId_45_F_, rpId_56_F_ }, + { rpId_45_N_, rpId_45_F_, rpId_56_N_, rpId_56_F_ }, + }; +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSAcceptancePlotter::analyze(const edm::Event& iEvent, const edm::EventSetup&) +{ + // get input + edm::Handle hHepMC; + iEvent.getByToken(tokenHepMC_, hHepMC); + HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent(); + + edm::Handle hTracks; + iEvent.getByToken(tokenTracks_, hTracks); + + // extract protons + bool proton_45_set = false; + bool proton_56_set = false; + FourVector mom_45, mom_56; + + for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) + { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + + if (mom.e() < 4500.) + continue; + + if (mom.z() > 0) + { + // 45 + if (proton_45_set) + { + LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 45."; + return; + } + + proton_45_set = true; + mom_45 = mom; + } else { + // 56 + if (proton_56_set) + { + LogError("CTPPSAcceptancePlotter") << "Multiple protons found in sector 56."; + return; + } + + proton_56_set = true; + mom_56 = mom; + } + } + + // stop if protons missing + if (!proton_45_set || !proton_56_set) + return; + + // calculate xi's + const double p_nom = 6500.; + const double xi_45 = (p_nom - mom_45.e()) / p_nom; + const double xi_56 = (p_nom - mom_56.e()) / p_nom; + + // process tracks + map trackPresent; + for (const auto& trk : *hTracks) + { + CTPPSDetId rpId(trk.getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + trackPresent[rpDecId] = true; + } + + // update plots + for (const auto rpIds : singleArmConfigurations) + { + bool acc = true; + signed int arm = -1; + for (const auto rpId : rpIds) + { + acc &= trackPresent[rpId]; + arm = rpId / 100; + } + + if (arm < 0) + continue; + + const double xi = (arm == 0) ? xi_45 : xi_56; + + singleArmPlots[rpIds].fill(xi, acc); + } + + for (const auto rpIds : doubleArmConfigurations) + { + bool acc = true; + for (const auto rpId : rpIds) + acc &= trackPresent[rpId]; + + doubleArmPlots[rpIds].fill(xi_45, xi_56, acc); + } +} + + +//---------------------------------------------------------------------------------------------------- + +void CTPPSAcceptancePlotter::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto &p : singleArmPlots) { + string dirName; + for (const auto &rpId : p.first) { + if (!dirName.empty()) + dirName += ","; + dirName += Form("%u", rpId); + } + + gDirectory = f_out->mkdir(dirName.c_str()); + p.second.write(); + } + + for (const auto &p : doubleArmPlots) { + string dirName; + for (const auto &rpId : p.first) { + if (!dirName.empty()) + dirName += ","; + dirName += Form("%u", rpId); + } + + gDirectory = f_out->mkdir(dirName.c_str()); + p.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSAcceptancePlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc new file mode 100644 index 0000000000000..896872d3cb337 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSBeamSmearingValidator.cc @@ -0,0 +1,164 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "TFile.h" +#include "TH1D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSBeamSmearingValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSBeamSmearingValidator( const edm::ParameterSet& ); + + ~CTPPSBeamSmearingValidator() override {} + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + + void endJob() override; + + edm::EDGetTokenT tokenBeforeSmearing_; + edm::EDGetTokenT tokenAfterSmearing_; + + std::string outputFile_; + + std::unique_ptr h_de_vtx_x_, h_de_vtx_y_, h_de_vtx_z_; + + struct SectorPlots + { + std::unique_ptr h_de_th_x, h_de_th_y, h_de_p; + + SectorPlots() : + h_de_th_x(new TH1D("", ";#Delta#theta_{x} (rad)", 100, 0., 0.)), + h_de_th_y(new TH1D("", ";#Delta#theta_{y} (rad)", 100, 0., 0.)), + h_de_p(new TH1D("", ";#Deltap (GeV)", 100, 0., 0.)) {} + + void write() const + { + h_de_th_x->Write("h_de_th_x"); + h_de_th_y->Write("h_de_th_y"); + h_de_p->Write("h_de_p"); + } + }; + + std::map sectorPlots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSBeamSmearingValidator::CTPPSBeamSmearingValidator(const edm::ParameterSet& iConfig) : + tokenBeforeSmearing_( consumes(iConfig.getParameter("tagBeforeSmearing")) ), + tokenAfterSmearing_( consumes(iConfig.getParameter("tagAfterSmearing")) ), + outputFile_(iConfig.getParameter("outputFile")), + h_de_vtx_x_(new TH1D("h_de_vtx_x", ";#Delta vtx_{x} (mm)", 100, 0., 0.)), + h_de_vtx_y_(new TH1D("h_de_vtx_y", ";#Delta vtx_{y} (mm)", 100, 0., 0.)), + h_de_vtx_z_(new TH1D("h_de_vtx_z", ";#Delta vtx_{z} (mm)", 100, 0., 0.)) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamSmearingValidator::analyze(const edm::Event& iEvent, const edm::EventSetup&) +{ + // get input + edm::Handle hBeforeSmearing; + iEvent.getByToken(tokenBeforeSmearing_, hBeforeSmearing); + HepMC::GenEvent *orig = (HepMC::GenEvent *) hBeforeSmearing->GetEvent(); + + edm::Handle hAfterSmearing; + iEvent.getByToken(tokenAfterSmearing_, hAfterSmearing); + HepMC::GenEvent *smear = (HepMC::GenEvent *) hAfterSmearing->GetEvent(); + + // vertices + GenEvent::vertex_const_iterator vold, vnew; + for (vold = orig->vertices_begin(), vnew = smear->vertices_begin(); + vold != orig->vertices_end() && vnew != smear->vertices_end(); ++vold, ++vnew) + { + const FourVector &vo = (*vold)->position(); + const FourVector &vn = (*vnew)->position(); + + // HepMC gives vertex in mm + h_de_vtx_x_->Fill(vn.x() - vo.x()); + h_de_vtx_y_->Fill(vn.y() - vo.y()); + h_de_vtx_z_->Fill(vn.z() - vo.z()); + } + + // particles + GenEvent::particle_const_iterator pold, pnew; + for (pold = orig->particles_begin(), pnew = smear->particles_begin(); + pold != orig->particles_end() && pnew != smear->particles_end(); ++pold, ++pnew) + { + FourVector o = (*pold)->momentum(), n = (*pnew)->momentum(); + + // determine direction region + signed int idx = -1; + const double thetaLim = 0.01; // rad + double th = o.theta(); + + if (th < thetaLim) + idx = 0; + if (th > (M_PI - thetaLim)) + idx = 1; + + if (idx < 0) + continue; + + /* + cout << "particle\n\told: [" << o.x() << ", " << o.y() << ", " << o.z() << ", " << o.t() + << "]\n\tnew: [" << n.x() << ", " << n.y() << ", " << n.z() << ", " << n.t() + << "]\n\tregion: " << idx << endl; + */ + + // fill histograms + auto &sp = sectorPlots_[idx]; + + double othx = o.x() / o.rho(), othy = o.y() / o.rho(); + double nthx = n.x() / n.rho(), nthy = n.y() / n.rho(); + + sp.h_de_p->Fill(n.rho() - o.rho()); + + sp.h_de_th_x->Fill(nthx - othx); + sp.h_de_th_y->Fill(nthy - othy); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSBeamSmearingValidator::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + h_de_vtx_x_->Write(); + h_de_vtx_y_->Write(); + h_de_vtx_z_->Write(); + + gDirectory = f_out->mkdir("sector 45"); + sectorPlots_[0].write(); + + gDirectory = f_out->mkdir("sector 56"); + sectorPlots_[1].write(); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSBeamSmearingValidator); + diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc new file mode 100644 index 0000000000000..d96d515054499 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -0,0 +1,481 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + * Laurent Forthomme + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h" + +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSDiamondRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + +#include "CondFormats/CTPPSReadoutObjects/interface/CTPPSBeamParameters.h" +#include "CondFormats/DataRecord/interface/CTPPSBeamParametersRcd.h" + +#include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometry.h" +#include "Geometry/Records/interface/VeryForwardMisalignedGeometryRecord.h" +#include "Geometry/VeryForwardRPTopology/interface/RPTopology.h" + +#include + +#include "TMath.h" +#include "TMatrixD.h" +#include "TVectorD.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSDirectProtonSimulation : public edm::stream::EDProducer<> +{ + public: + explicit CTPPSDirectProtonSimulation( const edm::ParameterSet& ); + ~CTPPSDirectProtonSimulation() override {} + + static void fillDescriptions( edm::ConfigurationDescriptions& descriptions ); + + private: + void produce( edm::Event&, const edm::EventSetup& ) override; + + void processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, + const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, + std::vector &out_tracks, + edm::DetSetVector& out_strip_hits, + edm::DetSetVector &out_pixel_hits, + edm::DetSetVector &out_diamond_hits) const; + + static bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2 = true) + { + float tmpXlocalCoordinate = xLocalCoordinate + (79*0.1 + 0.2); + float tmpYlocalCoordinate = yLocalCoordinate + (0.15*51 + 0.3*2 + 0.15*25); + + if(tmpXlocalCoordinate<0) return false; + if(tmpYlocalCoordinate<0) return false; + int xModuleSize = 0.1*79 + 0.2*2 + 0.1*79; // mm - 100 um pitch direction + int yModuleSize; // mm - 150 um pitch direction + if (is3x2) yModuleSize = 0.15*51 + 0.3*2 + 0.15*50 + 0.3*2 + 0.15*51; + else yModuleSize = 0.15*51 + 0.3*2 + 0.15*51; + if(tmpXlocalCoordinate>xModuleSize) return false; + if(tmpYlocalCoordinate>yModuleSize) return false; + return true; + } + + // ------------ config file parameters ------------ + + /// input tag + edm::EDGetTokenT hepMCToken_; + + /// flags what output to be produced + bool produceScoringPlaneHits_; + bool produceRecHits_; + + /// simulation parameters + bool checkApertures_; + + bool useEmpiricalApertures_; + double empiricalAperture45_xi0_, empiricalAperture45_a_; + double empiricalAperture56_xi0_, empiricalAperture56_a_; + + bool produceHitsRelativeToBeam_; + bool roundToPitch_; + bool checkIsHit_; + + double pitchStrips_; ///< strip pitch in mm + double insensitiveMarginStrips_; ///< size of insensitive margin at sensor's edge facing the beam, in mm + + double pitchPixelsHor_; + double pitchPixelsVer_; + + unsigned int verbosity_; + + // ------------ internal parameters ------------ + + /// internal variable: v position of strip 0, in mm + double stripZeroPosition_; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSDirectProtonSimulation::CTPPSDirectProtonSimulation( const edm::ParameterSet& iConfig ) : + hepMCToken_( consumes( iConfig.getParameter( "hepMCTag" ) ) ), + + produceScoringPlaneHits_( iConfig.getParameter( "produceScoringPlaneHits" ) ), + produceRecHits_( iConfig.getParameter( "produceRecHits" ) ), + + useEmpiricalApertures_( iConfig.getParameter( "useEmpiricalApertures" ) ), + empiricalAperture45_xi0_( iConfig.getParameter( "empiricalAperture45_xi0" ) ), + empiricalAperture45_a_( iConfig.getParameter( "empiricalAperture45_a" ) ), + empiricalAperture56_xi0_( iConfig.getParameter( "empiricalAperture56_xi0" ) ), + empiricalAperture56_a_( iConfig.getParameter( "empiricalAperture56_a" ) ), + + produceHitsRelativeToBeam_( iConfig.getParameter( "produceHitsRelativeToBeam" ) ), + roundToPitch_( iConfig.getParameter( "roundToPitch" ) ), + checkIsHit_( iConfig.getParameter( "checkIsHit" ) ), + + pitchStrips_( iConfig.getParameter( "pitchStrips" ) ), + insensitiveMarginStrips_( iConfig.getParameter( "insensitiveMarginStrips" ) ), + + pitchPixelsHor_( iConfig.getParameter( "pitchPixelsHor" ) ), + pitchPixelsVer_( iConfig.getParameter( "pitchPixelsVer" ) ), + + verbosity_( iConfig.getUntrackedParameter( "verbosity", 0 ) ) +{ + if (produceScoringPlaneHits_) + produces>(); + + if (produceRecHits_) + { + produces>(); + produces>(); + produces>(); + } + + // v position of strip 0 + stripZeroPosition_ = RPTopology::last_strip_to_border_dist_ + (RPTopology::no_of_strips_-1)*RPTopology::pitch_ - RPTopology::y_width_/2.; +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::produce( edm::Event& iEvent, const edm::EventSetup& iSetup ) +{ + // get input + edm::Handle hepmc_prod; + iEvent.getByToken(hepMCToken_, hepmc_prod); + + // get conditions + edm::ESHandle hBeamParameters; + iSetup.get().get(hBeamParameters); + + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); + + edm::ESHandle geometry; + iSetup.get().get(geometry); + + // prepare outputs + std::unique_ptr> pStripRecHits(new edm::DetSetVector()); + std::unique_ptr> pDiamondRecHits(new edm::DetSetVector()); + std::unique_ptr> pPixelRecHits(new edm::DetSetVector()); + + std::unique_ptr> pTracks(new std::vector()); + + // loop over event vertices + auto evt = new HepMC::GenEvent( *hepmc_prod->GetEvent() ); + for ( auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx ) + { + auto vtx = *( it_vtx ); + + // loop over outgoing particles + for ( auto it_part = vtx->particles_out_const_begin(); it_part != vtx->particles_out_const_end(); ++it_part ) + { + auto part = *( it_part ); + + // accept only stable protons + if ( part->pdg_id() != 2212 ) + continue; + + if ( part->status() != 1 && part->status() < 83 ) + continue; + + processProton(vtx, part, *geometry, *hBeamParameters, *hOpticalFunctions, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits); + } + } + + if (produceScoringPlaneHits_) + iEvent.put(std::move(pTracks)); + + if (produceRecHits_) + { + iEvent.put(std::move(pStripRecHits)); + iEvent.put(std::move(pPixelRecHits)); + iEvent.put(std::move(pDiamondRecHits)); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::processProton(const HepMC::GenVertex* in_vtx, const HepMC::GenParticle* in_trk, + const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, + const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, + std::vector &out_tracks, edm::DetSetVector& out_strip_hits, + edm::DetSetVector &out_pixel_hits, edm::DetSetVector &out_diamond_hits) const +{ + /// xi is positive for diffractive protons, thus proton momentum p = (1-xi) * p_nom + /// horizontal component of proton momentum: p_x = th_x * (1-xi) * p_nom + + std::stringstream ssLog; + + // vectors in CMS convention + const HepMC::FourVector& vtx_cms = in_vtx->position(); // in mm + const HepMC::FourVector& mom_cms = in_trk->momentum(); + + // transformation to LHC/TOTEM convention + HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t()); + HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t()); + + // determine the LHC arm and related parameters + unsigned int arm = 3; + double z_sign; + double beamMomentum = 0.; + double xangle = 0.; + double empiricalAperture_xi0, empiricalAperture_a; + + if (mom_lhc.z() < 0) // sector 45 + { + arm = 0; + z_sign = -1; + beamMomentum = beamParameters.getBeamMom45(); + xangle = beamParameters.getHalfXangleX45(); + empiricalAperture_xi0 = empiricalAperture45_xi0_; + empiricalAperture_a = empiricalAperture45_a_; + } else { // sector 56 + arm = 1; + z_sign = +1; + beamMomentum = beamParameters.getBeamMom56(); + xangle = beamParameters.getHalfXangleX56(); + empiricalAperture_xi0 = empiricalAperture56_xi0_; + empiricalAperture_a = empiricalAperture56_a_; + } + + // calculate kinematics for optics parametrisation + const double p = mom_lhc.rho(); + const double xi = 1. - p / beamMomentum; + const double th_x_phys = mom_lhc.x() / p; + const double th_y_phys = mom_lhc.y() / p; + const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle); + const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z()); + + if (verbosity_) + { + ssLog << "simu: xi = " << xi << ", th_x_phys = " << th_x_phys << ", th_y_phys = " << th_y_phys + << ", vtx_lhc_eff_x = " << vtx_lhc_eff_x << ", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl; + } + + // check empirical aperture + if (useEmpiricalApertures_) + { + const double xi_th = empiricalAperture_xi0 + th_x_phys * empiricalAperture_a; + if (xi > xi_th) + { + if (verbosity_) + { + ssLog << "stop because of empirical appertures"; + edm::LogInfo("CTPPSDirectProtonSimulation") << ssLog.str(); + } + + return; + } + } + + // transport the proton into each pot/scoring plane + for (const auto &ofp : opticalFunctions) + { + CTPPSDetId rpId(ofp.first); + const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + // first check the arm + if (rpId.arm() != arm) + continue; + + if (verbosity_) + ssLog << " RP " << rpDecId << std::endl; + + // transport proton + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { vtx_lhc_eff_x*1E-1, th_x_phys, vtx_lhc_eff_y*1E-1, th_y_phys, xi }; // conversions: mm -> cm + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; + ofp.second.transport(k_in, k_out, true); + + double b_x = k_out.x * 1E1, b_y = k_out.y * 1E1; // conversions: cm -> mm + double a_x = k_out.th_x, a_y = k_out.th_y; + + // if needed, subtract beam position and angle + if (produceHitsRelativeToBeam_) + { + // determine beam position + LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_in = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_out; + ofp.second.transport(k_be_in, k_be_out, true); + + a_x -= k_be_out.th_x; a_y -= k_be_out.th_y; + b_x -= k_be_out.x * 1E1; b_y -= k_be_out.y * 1E1; // conversions: cm -> mm + } + + const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1; // conversion: cm --> mm + + if (verbosity_) + { + ssLog << " proton transported: a_x = " << a_x << " rad, a_y = " << a_y << " rad, b_x = " << b_x << + " mm, b_y = " << b_y << " mm, z = " << z_scoringPlane << " mm" << std::endl; + } + + // save scoring plane hit + if (produceScoringPlaneHits_) + out_tracks.emplace_back(rpId.rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0., CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.); + + // stop if rec hits are not to be produced + if (!produceRecHits_) + continue; + + // loop over all sensors in the RP + for (const auto& detIdInt : geometry.getSensorsInRP(rpId)) + { + CTPPSDetId detId(detIdInt); + + // determine the track impact point (in global coordinates) + // !! this assumes that local axes (1, 0, 0) and (0, 1, 0) describe the sensor surface + CLHEP::Hep3Vector gl_o = geometry.localToGlobal(detId, CLHEP::Hep3Vector(0, 0, 0)); + CLHEP::Hep3Vector gl_a1 = geometry.localToGlobal(detId, CLHEP::Hep3Vector(1, 0, 0)) - gl_o; + CLHEP::Hep3Vector gl_a2 = geometry.localToGlobal(detId, CLHEP::Hep3Vector(0, 1, 0)) - gl_o; + + TMatrixD A(3, 3); + TVectorD B(3); + A(0, 0) = a_x; A(0, 1) = -gl_a1.x(); A(0, 2) = -gl_a2.x(); B(0) = gl_o.x() - b_x; + A(1, 0) = a_y; A(1, 1) = -gl_a1.y(); A(1, 2) = -gl_a2.y(); B(1) = gl_o.y() - b_y; + A(2, 0) = z_sign; A(2, 1) = -gl_a1.z(); A(2, 2) = -gl_a2.z(); B(2) = gl_o.z() - z_scoringPlane; + TMatrixD Ai(3, 3); + Ai = A.Invert(); + TVectorD P(3); + P = Ai * B; + + double ze = P(0); + CLHEP::Hep3Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign*ze + z_scoringPlane); + + // hit in local coordinates + CLHEP::Hep3Vector h_loc = geometry.globalToLocal(detId, h_glo); + + if (verbosity_) + { + ssLog << std::endl + << " de z = " << P(0) << " mm, p1 = " << P(1) << " mm, p2 = " << P(2) << " mm" << std::endl + << " h_glo: x = " << h_glo.x() << " mm, y = " << h_glo.y() << " mm, z = " << h_glo.z() << " mm" << std::endl + << " h_loc: c1 = " << h_loc.x() << " mm, c2 = " << h_loc.y() << " mm, c3 = " << h_loc.z() << " mm" << std::endl; + } + + // strips + if (detId.subdetId() == CTPPSDetId::sdTrackingStrip) + { + double u = h_loc.x(); + double v = h_loc.y(); + + if (verbosity_ > 5) + ssLog << " u=" << u << ", v=" << v; + + // is it within detector? + if (checkIsHit_ && !RPTopology::IsHit(u, v, insensitiveMarginStrips_)) + { + if (verbosity_ > 5) + ssLog << " | no hit" << std::endl; + continue; + } + + // round the measurement + if (roundToPitch_) + { + double m = stripZeroPosition_ - v; + signed int strip = (int) floor(m / pitchStrips_ + 0.5); + + v = stripZeroPosition_ - pitchStrips_ * strip; + + if (verbosity_ > 5) + ssLog << " | strip=" << strip; + } + + double sigma = pitchStrips_ / sqrt(12.); + + if (verbosity_ > 5) + ssLog << " | m=" << v << ", sigma=" << sigma << std::endl; + + edm::DetSet &hits = out_strip_hits.find_or_insert(detId); + hits.push_back(TotemRPRecHit(v, sigma)); + } + + // diamonds + if (detId.subdetId() == CTPPSDetId::sdTimingDiamond) + { + throw cms::Exception("CTPPSDirectProtonSimulation") << "Diamonds are not yet supported."; + } + + // pixels + if (detId.subdetId() == CTPPSDetId::sdTrackingPixel) + { + if (verbosity_) + { + CTPPSPixelDetId pixelDetId(detIdInt); + ssLog << " pixel plane " << pixelDetId.plane() << ": local hit x = " << h_loc.x() + << " mm, y = " << h_loc.y() << " mm, z = " << h_loc.z() << " mm" << std::endl; + } + + if (checkIsHit_ && !isPixelHit(h_loc.x(), h_loc.y())) + continue; + + if (roundToPitch_) + { + h_loc.setX( pitchPixelsHor_ * floor(h_loc.x()/pitchPixelsHor_ + 0.5) ); + h_loc.setY( pitchPixelsVer_ * floor(h_loc.y()/pitchPixelsVer_ + 0.5) ); + } + + if (verbosity_ > 5) + ssLog << " hit accepted: m1 = " << h_loc.x() << " mm, m2 = " << h_loc.y() << " mm" << std::endl; + + const double sigmaHor = pitchPixelsHor_ / sqrt(12.); + const double sigmaVer = pitchPixelsVer_ / sqrt(12.); + + const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z()); + const LocalError le(sigmaHor, 0., sigmaVer); + + edm::DetSet &hits = out_pixel_hits.find_or_insert(detId); + hits.push_back(CTPPSPixelRecHit(lp, le)); + } + } + } + + if (verbosity_) + edm::LogInfo("CTPPSDirectProtonSimulation") << ssLog.str(); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulation::fillDescriptions( edm::ConfigurationDescriptions& descriptions ) +{ + edm::ParameterSetDescription desc; + desc.addUntracked("verbosity", 0); + desc.add("hepMCTag", edm::InputTag("generator", "unsmeared")); + desc.add("produceScoringPlaneHits", true); + desc.add("produceRecHits", true); + desc.add("useEmpiricalApertures", false); + desc.add("empiricalAperture45_xi0", 0.); + desc.add("empiricalAperture45_a", 0.); + desc.add("empiricalAperture56_xi0", 0.); + desc.add("empiricalAperture56_a", 0.); + desc.add("produceHitsRelativeToBeam", false); + desc.add("roundToPitch", true); + desc.add("checkIsHit", true); + desc.add("pitchStrips", 66.e-3); // in mm + desc.add("insensitiveMarginStrips", 34.e-3); // in mm + desc.add("pitchPixelsHor", 100.e-3)->setComment("x in local coordinates, in mm"); + desc.add("pitchPixelsVer", 150.e-3)->setComment("y in local coordinates, in mm"); + + descriptions.add("ctppsDirectProtonSimulation", desc); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSDirectProtonSimulation ); diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc new file mode 100644 index 0000000000000..b1b859ad7139e --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulationValidator.cc @@ -0,0 +1,125 @@ +/**************************************************************************** + * + * This is a part of CTPPS validation software + * Authors: + * Jan Kašpar + * Laurent Forthomme + * + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSDirectProtonSimulationValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& ); + + private: + void beginJob() override {} + void analyze( const edm::Event&, const edm::EventSetup& ) override; + void endJob() override; + + edm::EDGetTokenT simuTracksToken_; + edm::EDGetTokenT recoTracksToken_; + + std::string outputFile_; + + struct RPPlots + { + std::unique_ptr h2_xr_vs_xs, h2_yr_vs_ys; + std::unique_ptr h_de_x, h_de_y; + + RPPlots() : + h2_xr_vs_xs( new TH2D("", "", 100, -10., +10., 100, -10, +10.) ), + h2_yr_vs_ys( new TH2D("", "", 100, -10., +10., 100, -10, +10.) ), + h_de_x( new TH1D("", "", 100, -0., +0.) ), + h_de_y( new TH1D("", "", 100, -0., +0.) ) + {} + + void fill(double simu_x, double simu_y, double reco_x, double reco_y) + { + h2_xr_vs_xs->Fill(simu_x, reco_x); + h2_yr_vs_ys->Fill(simu_y, reco_y); + + h_de_x->Fill(reco_x - simu_x); + h_de_y->Fill(reco_y - simu_y); + } + + void write() const + { + h2_xr_vs_xs->Write("h2_xr_vs_xs"); + h2_yr_vs_ys->Write("h2_yr_vs_ys"); + h_de_x->Write("h_de_x"); + h_de_y->Write("h_de_y"); + } + }; + + std::map rpPlots_; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSDirectProtonSimulationValidator::CTPPSDirectProtonSimulationValidator( const edm::ParameterSet& iConfig ) : + simuTracksToken_( consumes( iConfig.getParameter( "simuTracksTag" ) ) ), + recoTracksToken_( consumes( iConfig.getParameter( "recoTracksTag" ) ) ), + outputFile_( iConfig.getParameter("outputFile") ) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulationValidator::analyze( const edm::Event& iEvent, const edm::EventSetup& ) +{ + // get input + edm::Handle simuTracks; + iEvent.getByToken( simuTracksToken_, simuTracks ); + + edm::Handle recoTracks; + iEvent.getByToken( recoTracksToken_, recoTracks ); + + // process tracks + for (const auto& simuTrack : *simuTracks) { + const CTPPSDetId rpId(simuTrack.getRPId()); + for (const auto& recoTrack : *recoTracks) { + if (simuTrack.getRPId() == recoTrack.getRPId()) { + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + rpPlots_[rpDecId].fill(simuTrack.getX(), simuTrack.getY(), recoTrack.getX(), recoTrack.getY()); + } + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSDirectProtonSimulationValidator::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& it : rpPlots_) { + gDirectory = f_out->mkdir(Form("RP %u", it.first)); + it.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSDirectProtonSimulationValidator ); + diff --git a/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc new file mode 100644 index 0000000000000..b487eb17c19a8 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSHepMCDistributionPlotter.cc @@ -0,0 +1,119 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "TFile.h" +#include "TH1D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSHepMCDistributionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSHepMCDistributionPlotter(const edm::ParameterSet&); + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::EDGetTokenT tokenHepMC_; + std::string lhcInfoLabel_; + std::string outputFile_; + + std::unique_ptr h_xi_, h_th_x_, h_th_y_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSHepMCDistributionPlotter::CTPPSHepMCDistributionPlotter(const edm::ParameterSet& iConfig) : + tokenHepMC_( consumes(iConfig.getParameter("tagHepMC")) ), + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), + outputFile_(iConfig.getParameter("outputFile")), + h_xi_(new TH1D("h_xi", ";#xi", 100, 0., 0.30)), + h_th_x_(new TH1D("h_th_x", ";#theta^{*}_{x}", 100, -300E-6, +300E-6)), + h_th_y_(new TH1D("h_th_y", ";#theta^{*}_{y}", 100, -300E-6, +300E-6)) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSHepMCDistributionPlotter::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(lhcInfoLabel_, hLHCInfo); + + // get input + edm::Handle hHepMC; + iEvent.getByToken(tokenHepMC_, hHepMC); + HepMC::GenEvent *hepMCEvent = (HepMC::GenEvent *) hHepMC->GetEvent(); + + // extract protons + for (auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) + { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + const double p_nom = hLHCInfo->energy(); + + if (mom.rho() / p_nom < 0.7) + continue; + + const double xi_simu = (p_nom - mom.e()) / p_nom; + const double th_x_simu = mom.x() / mom.rho(); + const double th_y_simu = mom.y() / mom.rho(); + + h_xi_->Fill(xi_simu); + h_th_x_->Fill(th_x_simu); + h_th_y_->Fill(th_y_simu); + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSHepMCDistributionPlotter::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + h_xi_->Write(); + h_th_x_->Write(); + h_th_y_->Write(); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSHepMCDistributionPlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc new file mode 100644 index 0000000000000..a66c7ff5ac0d6 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionPlotter.cc @@ -0,0 +1,504 @@ +/**************************************************************************** +* Authors: +* Jan Kašpar (jan.kaspar@gmail.com) +****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" + +#include "TFile.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionPlotter(const edm::ParameterSet&); + ~CTPPSProtonReconstructionPlotter() override {} + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + + void endJob() override; + + edm::EDGetTokenT tokenTracks_; + edm::EDGetTokenT tokenRecoProtonsSingleRP_; + edm::EDGetTokenT tokenRecoProtonsMultiRP_; + + unsigned int rpId_45_N_, rpId_45_F_; + unsigned int rpId_56_N_, rpId_56_F_; + + std::string outputFile_; + + signed int maxNonEmptyEvents_; + + static void profileToRMSGraph(TProfile *p, TGraphErrors *g) + { + for (int bi = 1; bi <= p->GetNbinsX(); ++bi) + { + double c = p->GetBinCenter(bi); + + double N = p->GetBinEntries(bi); + double Sy = p->GetBinContent(bi) * N; + double Syy = p->GetSumw2()->At(bi); + + double si_sq = Syy/N - Sy*Sy/N/N; + double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; + double si_unc_sq = si_sq / 2. / N; // Gaussian approximation + double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; + + int idx = g->GetN(); + g->SetPoint(idx, c, si); + g->SetPointError(idx, 0., si_unc); + } + } + + struct SingleRPPlots + { + std::unique_ptr h_xi; + std::unique_ptr h2_th_y_vs_xi; + std::unique_ptr p_th_y_vs_xi; + + SingleRPPlots() : + h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)) + {} + + void fill(const reco::ForwardProton &p) + { + if (p.validFit()) { + h_xi->Fill(p.xi()); + + const double th_y = p.thetaY(); + h2_th_y_vs_xi->Fill(p.xi(), th_y); + p_th_y_vs_xi->Fill(p.xi(), th_y); + } + } + + void write() const + { + h_xi->Write("h_xi"); + + h2_th_y_vs_xi->Write("h2_th_y_vs_xi"); + p_th_y_vs_xi->Write("p_th_y_vs_xi"); + } + }; + + std::map singleRPPlots_; + + struct MultiRPPlots + { + std::unique_ptr h_xi, h_th_x, h_th_y, h_vtx_y, h_t, h_chi_sq, h_chi_sq_norm; + std::unique_ptr h_t_xi_range1, h_t_xi_range2, h_t_xi_range3; + std::unique_ptr h2_th_x_vs_xi, h2_th_y_vs_xi, h2_vtx_y_vs_xi, h2_t_vs_xi; + std::unique_ptr p_th_x_vs_xi, p_th_y_vs_xi, p_vtx_y_vs_xi; + + MultiRPPlots() : + h_xi(new TH1D("", ";#xi", 100, 0., 0.25)), + h_th_x(new TH1D("", ";#theta_{x} (rad)", 100, -500E-6, +500E-6)), + h_th_y(new TH1D("", ";#theta_{y} (rad)", 100, -500E-6, +500E-6)), + h_vtx_y(new TH1D("", ";vtx_{y} (cm)", 100, -2., +2.)), + h_chi_sq(new TH1D("", ";#chi^{2}", 100, 0., 0.)), + h_chi_sq_norm(new TH1D("", ";#chi^{2}/ndf", 100, 0., 5.)), + h2_th_x_vs_xi(new TH2D("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + h2_th_y_vs_xi(new TH2D("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25, 100, -500E-6, +500E-6)), + h2_vtx_y_vs_xi(new TH2D("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25, 100, -500E-3, +500E-3)), + p_th_x_vs_xi(new TProfile("", ";#xi;#theta_{x} (rad)", 100, 0., 0.25)), + p_th_y_vs_xi(new TProfile("", ";#xi;#theta_{y} (rad)", 100, 0., 0.25)), + p_vtx_y_vs_xi(new TProfile("", ";#xi;vtx_{y} (cm)", 100, 0., 0.25)) + { + std::vector v_t_bin_edges; + for (double t = 0; t <= 5.; ) { + v_t_bin_edges.push_back(t); + const double de_t = 0.05 + 0.09 * t + 0.02 * t*t; + t += de_t; + } + h_t.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range1.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range2.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h_t_xi_range3.reset(new TH1D("", ";|t| (GeV^2)", v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + h2_t_vs_xi.reset(new TH2D("", ";#xi;|t| (GeV^2)", 100, 0., 0.25, v_t_bin_edges.size() - 1, v_t_bin_edges.data())); + } + + void fill(const reco::ForwardProton &p) + { + if (!p.validFit()) + return; + + const double th_x = p.thetaX(); + const double th_y = p.thetaY(); + const double mt = - p.t(); + + h_chi_sq->Fill(p.chi2()); + if (p.ndof() > 0) + h_chi_sq_norm->Fill(p.normalizedChi2()); + + h_xi->Fill(p.xi()); + + h_th_x->Fill(th_x); + h_th_y->Fill(th_y); + + h_vtx_y->Fill(p.vertex().y()); + + h_t->Fill(mt); + if (p.xi() > 0.04 && p.xi() < 0.07) h_t_xi_range1->Fill(mt); + if (p.xi() > 0.07 && p.xi() < 0.10) h_t_xi_range2->Fill(mt); + if (p.xi() > 0.10 && p.xi() < 0.13) h_t_xi_range3->Fill(mt); + + h2_th_x_vs_xi->Fill(p.xi(), th_x); + h2_th_y_vs_xi->Fill(p.xi(), th_y); + h2_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); + h2_t_vs_xi->Fill(p.xi(), mt); + + p_th_x_vs_xi->Fill(p.xi(), th_x); + p_th_y_vs_xi->Fill(p.xi(), th_y); + p_vtx_y_vs_xi->Fill(p.xi(), p.vertex().y()); + } + + void write() const + { + h_chi_sq->Write("h_chi_sq"); + h_chi_sq_norm->Write("h_chi_sq_norm"); + + h_xi->Write("h_xi"); + + h_th_x->Write("h_th_x"); + h2_th_x_vs_xi->Write("h2_th_x_vs_xi"); + p_th_x_vs_xi->Write("p_th_x_vs_xi"); + auto g_th_x_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_th_x_vs_xi.get(), g_th_x_RMS_vs_xi.get()); + g_th_x_RMS_vs_xi->Write("g_th_x_RMS_vs_xi"); + + h_th_y->Write("h_th_y"); + h2_th_y_vs_xi->Write("h2_th_y_vs_xi"); + p_th_y_vs_xi->Write("p_th_y_vs_xi"); + auto g_th_y_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_th_y_vs_xi.get(), g_th_y_RMS_vs_xi.get()); + g_th_y_RMS_vs_xi->Write("g_th_y_RMS_vs_xi"); + + h_vtx_y->Write("h_vtx_y"); + h2_vtx_y_vs_xi->Write("h2_vtx_y_vs_xi"); + p_vtx_y_vs_xi->Write("p_vtx_y_vs_xi"); + auto g_vtx_y_RMS_vs_xi = std::make_unique(); + profileToRMSGraph(p_vtx_y_vs_xi.get(), g_vtx_y_RMS_vs_xi.get()); + g_vtx_y_RMS_vs_xi->Write("g_vtx_y_RMS_vs_xi"); + + h_t->Write("h_t"); + h_t_xi_range1->Write("h_t_xi_range1"); + h_t_xi_range2->Write("h_t_xi_range2"); + h_t_xi_range3->Write("h_t_xi_range3"); + + h2_t_vs_xi->Write("h2_t_vs_xi"); + } + }; + + std::map multiRPPlots_; + + struct SingleMultiCorrelationPlots + { + std::unique_ptr h2_xi_mu_vs_xi_si; + std::unique_ptr h_xi_diff_mu_si, h_xi_diff_si_mu; + + std::unique_ptr h2_xi_diff_si_mu_vs_xi_mu; + std::unique_ptr p_xi_diff_si_mu_vs_xi_mu; + + std::unique_ptr h2_th_y_mu_vs_th_y_si; + + SingleMultiCorrelationPlots() : + h2_xi_mu_vs_xi_si(new TH2D("", ";#xi_{single};#xi_{multi}", 100, 0., 0.25, 100, 0., 0.25)), + h_xi_diff_mu_si(new TH1D("", ";#xi_{multi} - #xi_{single}", 100, -0.1, +0.1)), + h_xi_diff_si_mu(new TH1D("", ";#xi_{single} - #xi_{multi}", 100, -0.1, +0.1)), + h2_xi_diff_si_mu_vs_xi_mu(new TH2D("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25, 100, -0.10, 0.10)), + p_xi_diff_si_mu_vs_xi_mu(new TProfile("", ";#xi_{multi};#xi_{single} - #xi_{multi}", 100, 0., 0.25)), + h2_th_y_mu_vs_th_y_si(new TH2D("", ";#theta^{*}_{y,si};#theta^{*}_{y,mu}", 100, -500E-6, +500E-6, 100, -500E-6, +500E-6)) + {} + + void fill(const reco::ForwardProton &p_single, const reco::ForwardProton &p_multi) + { + if (p_single.validFit() && p_multi.validFit()) { + h2_xi_mu_vs_xi_si->Fill(p_single.xi(), p_multi.xi()); + h_xi_diff_mu_si->Fill(p_multi.xi() - p_single.xi()); + h_xi_diff_si_mu->Fill(p_single.xi() - p_multi.xi()); + + h2_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.xi(), p_single.xi() - p_multi.xi()); + p_xi_diff_si_mu_vs_xi_mu->Fill(p_multi.xi(), p_single.xi() - p_multi.xi()); + + const double th_y_si = p_single.thetaY(); + const double th_y_mu = p_multi.thetaY(); + + h2_th_y_mu_vs_th_y_si->Fill(th_y_si, th_y_mu); + } + } + + void write() const + { + h2_xi_mu_vs_xi_si->Write("h2_xi_mu_vs_xi_si"); + h_xi_diff_mu_si->Write("h_xi_diff_mu_si"); + h_xi_diff_si_mu->Write("h_xi_diff_si_mu"); + + h2_xi_diff_si_mu_vs_xi_mu->Write("h2_xi_diff_si_mu_vs_xi_mu"); + p_xi_diff_si_mu_vs_xi_mu->Write("p_xi_diff_si_mu_vs_xi_mu"); + + h2_th_y_mu_vs_th_y_si->Write("h2_th_y_mu_vs_th_y_si"); + } + }; + + std::map singleMultiCorrelationPlots_; + + struct ArmCorrelationPlots + { + std::unique_ptr h_xi_si_diffNF; + std::unique_ptr p_xi_si_diffNF_vs_xi_mu; + + std::unique_ptr h_th_y_si_diffNF; + std::unique_ptr p_th_y_si_diffNF_vs_xi_mu; + + ArmCorrelationPlots() : + h_xi_si_diffNF(new TH1D("", ";#xi_{sF} - #xi_{sN}", 100, -0.02, +0.02)), + p_xi_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#xi_{sF} - #xi_{sN}", 100, 0., 0.25)), + h_th_y_si_diffNF(new TH1D("", ";#theta_{y,sF} - #theta_{y,sN}", 100, -100E-6, +100E-6)), + p_th_y_si_diffNF_vs_xi_mu(new TProfile("", ";#xi_{m};#theta_{y,sF} - #theta_{y,sN}", 100, 0., 0.25)) + {} + + void fill(const reco::ForwardProton &p_s_N, const reco::ForwardProton &p_s_F, const reco::ForwardProton &p_m) + { + if (!p_s_N.validFit() || !p_s_F.validFit() || !p_m.validFit()) + return; + + const double th_y_s_N = p_s_N.thetaY(); + const double th_y_s_F = p_s_F.thetaY(); + + h_xi_si_diffNF->Fill(p_s_F.xi() - p_s_N.xi()); + p_xi_si_diffNF_vs_xi_mu->Fill(p_m.xi(), p_s_F.xi() - p_s_N.xi()); + + h_th_y_si_diffNF->Fill(th_y_s_F - th_y_s_N); + p_th_y_si_diffNF_vs_xi_mu->Fill(p_m.xi(), th_y_s_F - th_y_s_N); + } + + void write() const + { + h_xi_si_diffNF->Write("h_xi_si_diffNF"); + p_xi_si_diffNF_vs_xi_mu->Write("p_xi_si_diffNF_vs_xi_mu"); + + h_th_y_si_diffNF->Write("h_th_y_si_diffNF"); + p_th_y_si_diffNF_vs_xi_mu->Write("p_th_y_si_diffNF_vs_xi_mu"); + } + }; + + std::map armCorrelationPlots_; + + std::unique_ptr p_x_L_diffNF_vs_x_L_N_, p_x_R_diffNF_vs_x_R_N_; + std::unique_ptr p_y_L_diffNF_vs_y_L_N_, p_y_R_diffNF_vs_y_R_N_; + + signed int n_non_empty_events_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionPlotter::CTPPSProtonReconstructionPlotter(const edm::ParameterSet &ps) : + tokenTracks_ (consumes(ps.getParameter("tagTracks"))), + tokenRecoProtonsSingleRP_(consumes(ps.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_ (consumes(ps.getParameter("tagRecoProtonsMultiRP"))), + + rpId_45_N_(ps.getParameter("rpId_45_N")), + rpId_45_F_(ps.getParameter("rpId_45_F")), + rpId_56_N_(ps.getParameter("rpId_56_N")), + rpId_56_F_(ps.getParameter("rpId_56_F")), + + outputFile_(ps.getParameter("outputFile")), + maxNonEmptyEvents_(ps.getUntrackedParameter("maxNonEmptyEvents", -1)), + + p_x_L_diffNF_vs_x_L_N_(new TProfile("p_x_L_diffNF_vs_x_L_N", ";x_{LN};x_{LF} - x_{LN}", 100, 0., +20.)), + p_x_R_diffNF_vs_x_R_N_(new TProfile("p_x_R_diffNF_vs_x_R_N", ";x_{RN};x_{RF} - x_{RN}", 100, 0., +20.)), + + p_y_L_diffNF_vs_y_L_N_(new TProfile("p_y_L_diffNF_vs_y_L_N", ";y_{LN};y_{LF} - y_{LN}", 100, -20., +20.)), + p_y_R_diffNF_vs_y_R_N_(new TProfile("p_y_R_diffNF_vs_y_R_N", ";y_{RN};y_{RF} - y_{RN}", 100, -20., +20.)), + + n_non_empty_events_(0) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionPlotter::analyze(const edm::Event &event, const edm::EventSetup&) +{ + // get input + edm::Handle hTracks; + event.getByToken(tokenTracks_, hTracks); + + Handle hRecoProtonsSingleRP; + event.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + Handle hRecoProtonsMultiRP; + event.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + + if (!hRecoProtonsSingleRP->empty()) + n_non_empty_events_++; + + if (maxNonEmptyEvents_ > 0 && n_non_empty_events_ > maxNonEmptyEvents_) + throw cms::Exception("CTPPSProtonReconstructionPlotter") << "Number of non empty events reached maximum."; + + // track plots + const CTPPSLocalTrackLite *tr_L_N = nullptr; + const CTPPSLocalTrackLite *tr_L_F = nullptr; + const CTPPSLocalTrackLite *tr_R_N = nullptr; + const CTPPSLocalTrackLite *tr_R_F = nullptr; + + for (const auto &tr : *hTracks) + { + CTPPSDetId rpId(tr.getRPId()); + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (decRPId == rpId_45_N_) tr_L_N = &tr; + if (decRPId == rpId_45_F_) tr_L_F = &tr; + if (decRPId == rpId_56_N_) tr_R_N = &tr; + if (decRPId == rpId_56_F_) tr_R_F = &tr; + } + + if (tr_L_N && tr_L_F) + { + p_x_L_diffNF_vs_x_L_N_->Fill(tr_L_N->getX(), tr_L_F->getX() - tr_L_N->getX()); + p_y_L_diffNF_vs_y_L_N_->Fill(tr_L_N->getY(), tr_L_F->getY() - tr_L_N->getY()); + } + + if (tr_R_N && tr_R_F) + { + p_x_R_diffNF_vs_x_R_N_->Fill(tr_R_N->getX(), tr_R_F->getX() - tr_R_N->getX()); + p_y_R_diffNF_vs_y_R_N_->Fill(tr_R_N->getY(), tr_R_F->getY() - tr_R_N->getY()); + } + + // make single-RP-reco plots + for (const auto &proton : *hRecoProtonsSingleRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + unsigned int decRPId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + singleRPPlots_[decRPId].fill(proton); + } + + // make multi-RP-reco plots + for (const auto &proton : *hRecoProtonsMultiRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + unsigned int armId = rpId.arm(); + multiRPPlots_[armId].fill(proton); + } + + // make correlation plots + for (const auto &proton_s : *hRecoProtonsSingleRP) + { + for (const auto &proton_m : *hRecoProtonsMultiRP) + { + // only compare object from the same arm + CTPPSDetId rpId_s((*proton_s.contributingLocalTracks().begin())->getRPId()); + CTPPSDetId rpId_m((*proton_m.contributingLocalTracks().begin())->getRPId()); + + if (rpId_s.arm() != rpId_m.arm()) + continue; + + // build index + const unsigned int idx = rpId_s.arm()*1000 + rpId_s.station()*100 + rpId_s.rp()*10 + rpId_m.arm(); + + // fill plots + singleMultiCorrelationPlots_[idx].fill(proton_s, proton_m); + } + } + + // arm correlation plots + const reco::ForwardProton *p_arm0_s_N = nullptr, *p_arm0_s_F = nullptr, *p_arm0_m = nullptr; + const reco::ForwardProton *p_arm1_s_N = nullptr, *p_arm1_s_F = nullptr, *p_arm1_m = nullptr; + + for (const auto &proton : *hRecoProtonsSingleRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + const unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + if (rpDecId == rpId_45_N_) p_arm0_s_N = &proton; + if (rpDecId == rpId_45_F_) p_arm0_s_F = &proton; + + if (rpDecId == rpId_56_N_) p_arm1_s_N = &proton; + if (rpDecId == rpId_56_F_) p_arm1_s_F = &proton; + } + + for (const auto & proton : *hRecoProtonsMultiRP) + { + CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->getRPId()); + const unsigned int arm = rpId.arm(); + + if (arm == 0) p_arm0_m = &proton; + if (arm == 1) p_arm1_m = &proton; + } + + if (p_arm0_s_N && p_arm0_s_F && p_arm0_m) + armCorrelationPlots_[0].fill(*p_arm0_s_N, *p_arm0_s_F, *p_arm0_m); + + if (p_arm1_s_N && p_arm1_s_F && p_arm1_m) + armCorrelationPlots_[1].fill(*p_arm1_s_N, *p_arm1_s_F, *p_arm1_m); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionPlotter::endJob() +{ + LogInfo("CTPPSProtonReconstructionPlotter") << "n_non_empty_events = " << n_non_empty_events_; + + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + p_x_L_diffNF_vs_x_L_N_->Write(); + p_x_R_diffNF_vs_x_R_N_->Write(); + + p_y_L_diffNF_vs_y_L_N_->Write(); + p_y_R_diffNF_vs_y_R_N_->Write(); + + TDirectory *d_singleRPPlots = f_out->mkdir("singleRPPlots"); + for (const auto& it : singleRPPlots_) { + gDirectory = d_singleRPPlots->mkdir(Form("rp%u", it.first)); + it.second.write(); + } + + TDirectory *d_multiRPPlots = f_out->mkdir("multiRPPlots"); + for (const auto& it : multiRPPlots_) { + gDirectory = d_multiRPPlots->mkdir(Form("arm%u", it.first)); + it.second.write(); + } + + TDirectory *d_singleMultiCorrelationPlots = f_out->mkdir("singleMultiCorrelationPlots"); + for (const auto& it : singleMultiCorrelationPlots_) { + unsigned int si_rp = it.first / 10; + unsigned int mu_arm = it.first % 10; + + gDirectory = d_singleMultiCorrelationPlots->mkdir(Form("si_rp%u_mu_arm%u", si_rp, mu_arm)); + it.second.write(); + } + + TDirectory *d_armCorrelationPlots = f_out->mkdir("armCorrelationPlots"); + for (const auto& it : armCorrelationPlots_) { + gDirectory = d_armCorrelationPlots->mkdir(Form("arm%u", it.first)); + it.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionPlotter); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc new file mode 100644 index 0000000000000..a522e7be15a34 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionSimulationValidator.cc @@ -0,0 +1,348 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TGraphErrors.h" + +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionSimulationValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet&); + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + void fillPlots(unsigned int meth_idx, unsigned int idx, const reco::ForwardProton &rec_pr, + const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo); + + edm::EDGetTokenT tokenHepMCBeforeSmearing_; + edm::EDGetTokenT tokenHepMCAfterSmearing_; + + edm::EDGetTokenT tokenRecoProtonsSingleRP_; + edm::EDGetTokenT tokenRecoProtonsMultiRP_; + + std::string lhcInfoLabel_; + + std::string outputFile_; + + struct PlotGroup + { + std::unique_ptr h_de_xi; + std::unique_ptr p_de_xi_vs_xi_simu; + std::unique_ptr h_xi_reco_vs_xi_simu; + + std::unique_ptr h_de_th_x; + std::unique_ptr p_de_th_x_vs_xi_simu; + + std::unique_ptr h_de_th_y; + std::unique_ptr p_de_th_y_vs_xi_simu; + + std::unique_ptr h_de_vtx_y; + std::unique_ptr p_de_vtx_y_vs_xi_simu; + + std::unique_ptr h_de_t; + std::unique_ptr p_de_t_vs_xi_simu, p_de_t_vs_t_simu; + + PlotGroup() : + h_de_xi(new TH1D("", ";#xi_{reco} - #xi_{simu}", 100, 0., 0.)), + p_de_xi_vs_xi_simu(new TProfile("", ";#xi_{simu};#xi_{reco} - #xi_{simu}", 19, 0.015, 0.205)), + h_xi_reco_vs_xi_simu(new TH2D("", ";#xi_{simu};#xi_{reco}", 100, 0., 0.30, 100, 0., 0.30)), + + h_de_th_x(new TH1D("", ";#theta_{x,reco} - #theta_{x,simu}", 100, 0., 0.)), + p_de_th_x_vs_xi_simu(new TProfile("", ";#xi_{simu};#theta_{x,reco} - #theta_{x,simu}", 19, 0.015, 0.205)), + + h_de_th_y(new TH1D("", ";#theta_{y,reco} - #theta_{y,simu}", 100, 0., 0.)), + p_de_th_y_vs_xi_simu(new TProfile("", ";#xi_{simu};#theta_{y,reco} - #theta_{y,simu}", 19, 0.015, 0.205)), + + h_de_vtx_y(new TH1D("", ";vtx_{y,reco} - vtx_{y,simu} (mm)", 100, 0., 0.)), + p_de_vtx_y_vs_xi_simu(new TProfile("", ";#xi_{simu};vtx_{y,reco} - vtx_{y,simu} (mm)", 19, 0.015, 0.205)), + + h_de_t(new TH1D("", ";t_{reco} - t_{simu}", 100, -1., +1.)), + p_de_t_vs_xi_simu(new TProfile("", ";xi_{simu};t_{reco} - t_{simu}", 19, 0.015, 0.205)), + p_de_t_vs_t_simu(new TProfile("", ";t_{simu};t_{reco} - t_{simu}", 20, 0., 5.)) + {} + + static TGraphErrors profileToRMSGraph(TProfile *p, const char* name = "") + { + TGraphErrors gr_err; + gr_err.SetName(name); + + for (int bi = 1; bi <= p->GetNbinsX(); ++bi) { + double c = p->GetBinCenter(bi); + double w = p->GetBinWidth(bi); + + double N = p->GetBinEntries(bi); + double Sy = p->GetBinContent(bi) * N; + double Syy = p->GetSumw2()->At(bi); + + double si_sq = Syy/N - Sy*Sy/N/N; + double si = (si_sq >= 0.) ? sqrt(si_sq) : 0.; + double si_unc_sq = si_sq / 2. / N; // Gaussian approximation + double si_unc = (si_unc_sq >= 0.) ? sqrt(si_unc_sq) : 0.; + + int idx = gr_err.GetN(); + gr_err.SetPoint(idx, c, si); + gr_err.SetPointError(idx, w/2., si_unc); + } + + return gr_err; + } + + void write() const + { + h_xi_reco_vs_xi_simu->Write("h_xi_reco_vs_xi_simu"); + h_de_xi->Write("h_de_xi"); + p_de_xi_vs_xi_simu->Write("p_de_xi_vs_xi_simu"); + profileToRMSGraph(p_de_xi_vs_xi_simu.get(), "g_rms_de_xi_vs_xi_simu").Write(); + + h_de_th_x->Write("h_de_th_x"); + p_de_th_x_vs_xi_simu->Write("p_de_th_x_vs_xi_simu"); + profileToRMSGraph(p_de_th_x_vs_xi_simu.get(), "g_rms_de_th_x_vs_xi_simu").Write(); + + h_de_th_y->Write("h_de_th_y"); + p_de_th_y_vs_xi_simu->Write("p_de_th_y_vs_xi_simu"); + profileToRMSGraph(p_de_th_y_vs_xi_simu.get(), "g_rms_de_th_y_vs_xi_simu").Write(); + + h_de_vtx_y->Write("h_de_vtx_y"); + p_de_vtx_y_vs_xi_simu->Write("p_de_vtx_y_vs_xi_simu"); + profileToRMSGraph(p_de_vtx_y_vs_xi_simu.get(), "g_rms_de_vtx_y_vs_xi_simu").Write(); + + h_de_t->Write("h_de_t"); + p_de_t_vs_xi_simu->Write("p_de_t_vs_xi_simu"); + profileToRMSGraph(p_de_t_vs_xi_simu.get(), "g_rms_de_t_vs_xi_simu").Write(); + p_de_t_vs_t_simu->Write("p_de_t_vs_t_simu"); + profileToRMSGraph(p_de_t_vs_t_simu.get(), "g_rms_de_t_vs_t_simu").Write(); + } + }; + + std::map> plots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; +using namespace HepMC; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionSimulationValidator::CTPPSProtonReconstructionSimulationValidator(const edm::ParameterSet& iConfig) : + tokenHepMCBeforeSmearing_(consumes(iConfig.getParameter("tagHepMCBeforeSmearing"))), + tokenHepMCAfterSmearing_ (consumes(iConfig.getParameter("tagHepMCAfterSmearing"))), + tokenRecoProtonsSingleRP_(consumes(iConfig.getParameter("tagRecoProtonsSingleRP"))), + tokenRecoProtonsMultiRP_ (consumes(iConfig.getParameter("tagRecoProtonsMultiRP"))), + lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), + outputFile_(iConfig.getParameter("outputFile")) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + // get conditions + edm::ESHandle hLHCInfo; + iSetup.get().get(lhcInfoLabel_, hLHCInfo); + + // get input + edm::Handle hHepMCBeforeSmearing; + iEvent.getByToken(tokenHepMCBeforeSmearing_, hHepMCBeforeSmearing); + HepMC::GenEvent *hepMCEventBeforeSmearing = (HepMC::GenEvent *) hHepMCBeforeSmearing->GetEvent(); + + edm::Handle hHepMCAfterSmearing; + iEvent.getByToken(tokenHepMCAfterSmearing_, hHepMCAfterSmearing); + HepMC::GenEvent *hepMCEventAfterSmearing = (HepMC::GenEvent *) hHepMCAfterSmearing->GetEvent(); + + Handle hRecoProtonsSingleRP; + iEvent.getByToken(tokenRecoProtonsSingleRP_, hRecoProtonsSingleRP); + + Handle hRecoProtonsMultiRP; + iEvent.getByToken(tokenRecoProtonsMultiRP_, hRecoProtonsMultiRP); + + // extract vertex position + bool vertex_set = false; + FourVector vtx; + for (auto it = hepMCEventAfterSmearing->vertices_begin(); it != hepMCEventAfterSmearing->vertices_end(); ++it) { + if (vertex_set) { + LogError("CTPPSProtonReconstructionSimulationValidator") << "Multiple vertices found."; + return; + } + + vertex_set = true; + vtx = (*it)->position(); + } + + // extract forward protons + bool proton_45_set = false; + bool proton_56_set = false; + FourVector mom_45, mom_56; + + for (auto it = hepMCEventBeforeSmearing->particles_begin(); it != hepMCEventBeforeSmearing->particles_end(); ++it) { + const auto &part = *it; + + // accept only stable non-beam protons + if (part->pdg_id() != 2212) + continue; + + if (part->status() != 1) + continue; + + if (part->is_beam()) + continue; + + const auto &mom = part->momentum(); + + if (mom.e() < 4500.) + continue; + + if (mom.z() > 0) { + // 45 + if (proton_45_set) { + LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 45."; + return; + } + + proton_45_set = true; + mom_45 = mom; + } else { + // 56 + if (proton_56_set) { + LogError("CTPPSProtonReconstructionSimulationValidator") << "Found multiple protons in sector 56."; + return; + } + + proton_56_set = true; + mom_56 = mom; + } + } + + // do comparison + for (const auto& handle : { hRecoProtonsSingleRP, hRecoProtonsMultiRP } ) { + for (const auto& rec_pr : *handle) { + if (! rec_pr.validFit()) + continue; + + unsigned int idx; + + bool mom_set = false; + FourVector mom; + + if (rec_pr.lhcSector() == reco::ForwardProton::LHCSector::sector45) + { + idx = 0; + mom_set = proton_45_set; + mom = mom_45; + } else { + idx = 1; + mom_set = proton_56_set; + mom = mom_56; + } + + if (! mom_set) + continue; + + unsigned int meth_idx = 1234; + + if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::singleRP) { + meth_idx = 0; + + CTPPSDetId rpId((*rec_pr.contributingLocalTracks().begin())->getRPId()); + idx = 100*rpId.arm() + 10*rpId.station() + rpId.rp(); + } + + if (rec_pr.method() == reco::ForwardProton::ReconstructionMethod::multiRP) + meth_idx = 1; + + fillPlots(meth_idx, idx, rec_pr, vtx, mom, *hLHCInfo); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::fillPlots(unsigned int meth_idx, unsigned int idx, + const reco::ForwardProton &rec_pr, const HepMC::FourVector &vtx, const HepMC::FourVector &mom, const LHCInfo &lhcInfo) +{ + const double p_nom = lhcInfo.energy(); + const double xi_simu = (p_nom - mom.rho()) / p_nom; + const double th_x_simu = mom.x() / mom.rho(); + const double th_y_simu = mom.y() / mom.rho(); + const double vtx_y_simu = vtx.y(); + const double th_simu = sqrt(th_x_simu*th_x_simu + th_y_simu*th_y_simu); + const double t_simu = - reco::ForwardProton::calculateT(p_nom, mom.rho(), th_simu); + + const double xi_reco = rec_pr.xi(); + const double th_x_reco = rec_pr.thetaX(); + const double th_y_reco = rec_pr.thetaY(); + const double vtx_y_reco = rec_pr.vertex().y() * 10.; // conversion: cm --> mm + const double t_reco = - rec_pr.t(); + + auto& plt = plots_[meth_idx][idx]; + + plt.h_xi_reco_vs_xi_simu->Fill(xi_simu, xi_reco); + plt.h_de_xi->Fill(xi_reco - xi_simu); + plt.p_de_xi_vs_xi_simu->Fill(xi_simu, xi_reco - xi_simu); + + plt.h_de_th_x->Fill(th_x_reco - th_x_simu); + plt.p_de_th_x_vs_xi_simu->Fill(xi_simu, th_x_reco - th_x_simu); + + plt.h_de_th_y->Fill(th_y_reco - th_y_simu); + plt.p_de_th_y_vs_xi_simu->Fill(xi_simu, th_y_reco - th_y_simu); + + plt.h_de_vtx_y->Fill(vtx_y_reco - vtx_y_simu); + plt.p_de_vtx_y_vs_xi_simu->Fill(xi_simu, vtx_y_reco - vtx_y_simu); + + plt.h_de_t->Fill(t_reco - t_simu); + plt.p_de_t_vs_xi_simu->Fill(xi_simu, t_reco - t_simu); + plt.p_de_t_vs_t_simu->Fill(t_simu, t_reco - t_simu); +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionSimulationValidator::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& mit : plots_) { + const char* method = (mit.first == 0) ? "single rp" : "multi rp"; + TDirectory *d_method = f_out->mkdir(method); + + for (const auto& eit : mit.second) { + gDirectory = d_method->mkdir(Form("%i", eit.first)); + eit.second.write(); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionSimulationValidator); + diff --git a/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc new file mode 100644 index 0000000000000..437c5527edb6e --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSProtonReconstructionValidator.cc @@ -0,0 +1,143 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + +#include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" +#include "CondFormats/CTPPSReadoutObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" + +#include "DataFormats/ProtonReco/interface/ForwardProton.h" +#include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" + +#include "TFile.h" +#include "TH1D.h" + +#include +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSProtonReconstructionValidator : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSProtonReconstructionValidator(const edm::ParameterSet&); + + private: + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + edm::EDGetTokenT tokenRecoProtons_; + double chiSqCut_; + std::string outputFile_; + + struct RPPlots + { + std::unique_ptr h_de_x, h_de_y; + RPPlots() : + h_de_x(new TH1D("", ";#Deltax (mm)", 100, -2., +2.)), + h_de_y(new TH1D("", ";#Deltay (mm)", 100, -2., +2.)) + {} + + void fill(double de_x, double de_y) { + h_de_x->Fill(de_x); + h_de_y->Fill(de_y); + } + + void write() const { + h_de_x->Write("h_de_x"); + h_de_y->Write("h_de_y"); + } + }; + + std::map rp_plots_; +}; + +//---------------------------------------------------------------------------------------------------- + +using namespace std; +using namespace edm; + +//---------------------------------------------------------------------------------------------------- + +CTPPSProtonReconstructionValidator::CTPPSProtonReconstructionValidator(const edm::ParameterSet& iConfig) : + tokenRecoProtons_(consumes(iConfig.getParameter("tagRecoProtons"))), + chiSqCut_ (iConfig.getParameter("chiSqCut")), + outputFile_(iConfig.getParameter("outputFile")) +{} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionValidator::analyze(const edm::Event& iEvent, const edm::EventSetup &iSetup) +{ + // get conditions + edm::ESHandle hOpticalFunctions; + iSetup.get().get(hOpticalFunctions); + + // stop if conditions invalid + if (hOpticalFunctions->empty()) + return; + + // get input + Handle hRecoProtons; + iEvent.getByToken(tokenRecoProtons_, hRecoProtons); + + // process tracks + for (const auto &pr : *hRecoProtons) + { + if (! pr.validFit()) + continue; + + if (pr.chi2() > chiSqCut_) + continue; + + for (const auto &tr : pr.contributingLocalTracks()) + { + CTPPSDetId rpId(tr->getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + + auto it = hOpticalFunctions->find(rpId); + + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in_beam = { 0., 0., 0., 0., 0. }; + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out_beam; + it->second.transport(k_in_beam, k_out_beam); + + LHCInterpolatedOpticalFunctionsSet::Kinematics k_in = { -pr.vx(), -pr.thetaX(), pr.vy(), pr.thetaY(), pr.xi() }; // conversions: CMS --> LHC convention + LHCInterpolatedOpticalFunctionsSet::Kinematics k_out; + it->second.transport(k_in, k_out); + + const double de_x = (k_out.x - k_out_beam.x) * 10. - tr->getX(); // conversions: cm --> mm + const double de_y = (k_out.y - k_out_beam.y) * 10. - tr->getY(); // conversions: cm --> mm + + rp_plots_[rpDecId].fill(de_x, de_y); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSProtonReconstructionValidator::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& p : rp_plots_) { + gDirectory = f_out->mkdir(Form("%u", p.first)); + p.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(CTPPSProtonReconstructionValidator); + diff --git a/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc new file mode 100644 index 0000000000000..15d49f8e1a544 --- /dev/null +++ b/Validation/CTPPS/plugins/CTPPSTrackDistributionPlotter.cc @@ -0,0 +1,160 @@ +/**************************************************************************** + * + * This is a part of CTPPS validation software + * Authors: + * Jan Kašpar + * Laurent Forthomme + * + ****************************************************************************/ + + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLite.h" +#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" + +#include "TFile.h" +#include "TH2D.h" +#include "TProfile.h" +#include "TProfile2D.h" + +#include + +//---------------------------------------------------------------------------------------------------- + +class CTPPSTrackDistributionPlotter : public edm::one::EDAnalyzer<> +{ + public: + explicit CTPPSTrackDistributionPlotter(const edm::ParameterSet&); + + ~CTPPSTrackDistributionPlotter() override {} + + private: + void analyze( const edm::Event&, const edm::EventSetup& ) override; + void endJob() override; + + edm::EDGetTokenT tracksToken_; + + std::string outputFile_; + + struct RPPlots + { + std::unique_ptr h2_y_vs_x; + std::unique_ptr p_y_vs_x; + std::unique_ptr h_x; + + RPPlots() : + h2_y_vs_x(new TH2D("", "", 300, -10., +70., 300, -30, +30.)), + p_y_vs_x(new TProfile("", "", 300, -10., +70.)), + h_x(new TH1D("", "", 600, -10., +70.)) + {} + + void fill(double x, double y) + { + h2_y_vs_x->Fill(x, y); + p_y_vs_x->Fill(x, y); + h_x->Fill(x); + } + + void write() const + { + h2_y_vs_x->Write("h2_y_vs_x"); + p_y_vs_x->Write("p_y_vs_x"); + h_x->Write("h_x"); + } + }; + + std::map rpPlots; + + + struct ArmPlots + { + std::unique_ptr p2_de_x_vs_x_y, p2_de_y_vs_x_y; + + ArmPlots() : + p2_de_x_vs_x_y(new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.)), + p2_de_y_vs_x_y(new TProfile2D("", ";x;y", 40, 0., 40., 40, -20., +20.)) + {} + + void fill(double x_N, double y_N, double x_F, double y_F) + { + p2_de_x_vs_x_y->Fill(x_N, y_N, x_F - x_N); + p2_de_y_vs_x_y->Fill(x_N, y_N, y_F - y_N); + } + + void write() const + { + p2_de_x_vs_x_y->Write("p2_de_x_vs_x_y"); + p2_de_y_vs_x_y->Write("p2_de_y_vs_x_y"); + } + }; + + std::map armPlots; +}; + +//---------------------------------------------------------------------------------------------------- + +CTPPSTrackDistributionPlotter::CTPPSTrackDistributionPlotter( const edm::ParameterSet& iConfig ) : + tracksToken_( consumes( iConfig.getParameter( "tagTracks" ) ) ), + outputFile_( iConfig.getParameter("outputFile") ) +{ +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSTrackDistributionPlotter::analyze( const edm::Event& iEvent, const edm::EventSetup& ) +{ + // get input + edm::Handle tracks; + iEvent.getByToken( tracksToken_, tracks ); + + // process tracks + for (const auto& trk : *tracks) { + CTPPSDetId rpId(trk.getRPId()); + unsigned int rpDecId = rpId.arm()*100 + rpId.station()*10 + rpId.rp(); + rpPlots[rpDecId].fill(trk.getX(), trk.getY()); + } + + for (const auto& t1 : *tracks) { + CTPPSDetId rpId1(t1.getRPId()); + + for (const auto& t2 : *tracks) { + CTPPSDetId rpId2(t2.getRPId()); + + if (rpId1.arm() != rpId2.arm()) + continue; + + if (rpId1.station() == 0 && rpId2.station() == 2) + armPlots[rpId1.arm()].fill(t1.getX(), t1.getY(), t2.getX(), t2.getY()); + } + } +} + +//---------------------------------------------------------------------------------------------------- + +void CTPPSTrackDistributionPlotter::endJob() +{ + auto f_out = std::make_unique(outputFile_.c_str(), "recreate"); + + for (const auto& it : rpPlots) { + gDirectory = f_out->mkdir(Form("RP %u", it.first)); + it.second.write(); + } + + for (const auto& it : armPlots) { + gDirectory = f_out->mkdir(Form("arm %u", it.first)); + it.second.write(); + } +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE( CTPPSTrackDistributionPlotter ); + diff --git a/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py new file mode 100644 index 0000000000000..be79a60d09582 --- /dev/null +++ b/Validation/CTPPS/python/year_2016/ctppsBeamParametersESSource_cfi.py @@ -0,0 +1,40 @@ +import FWCore.ParameterSet.Config as cms + +ctppsBeamParametersESSource = cms.ESSource("CTPPSBeamParametersESSource", + setBeamPars = cms.bool(True), + + # beam momentum (GeV) + beamMom45 = cms.double(6500.), + beamMom56 = cms.double(6500.), + + # beta* (cm) + betaStarX45 = cms.double(0.), + betaStarX56 = cms.double(0.), + betaStarY45 = cms.double(0.), + betaStarY56 = cms.double(0.), + + # beam divergence (rad) + beamDivX45 = cms.double(20E-6), + beamDivX56 = cms.double(20E-6), + beamDivY45 = cms.double(20E-6), + beamDivY56 = cms.double(20E-6), + + # half crossing angle (rad) + halfXangleX45 = cms.double(179.394E-6), + halfXangleX56 = cms.double(191.541E-6), + halfXangleY45 = cms.double(0.), + halfXangleY56 = cms.double(0.), + + # vertex offset (cm) + vtxOffsetX45 = cms.double(0.), + vtxOffsetX56 = cms.double(0.), + vtxOffsetY45 = cms.double(0.), + vtxOffsetY56 = cms.double(0.), + vtxOffsetZ45 = cms.double(0.), + vtxOffsetZ56 = cms.double(0.), + + # vertex sigma (cm) + vtxStddevX = cms.double(10E-4), + vtxStddevY = cms.double(10E-4), + vtxStddevZ = cms.double(5) +) diff --git a/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py b/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py new file mode 100644 index 0000000000000..a7c10f034b0a9 --- /dev/null +++ b/Validation/CTPPS/python/year_2016/randomXiThetaGunProducer_cfi.py @@ -0,0 +1,17 @@ +import FWCore.ParameterSet.Config as cms + +generator = cms.EDProducer("RandomXiThetaGunProducer", + particleId = cms.uint32(2212), + + energy = cms.double(6500), # nominal beam energy, GeV + + xi_min = cms.double(0.), + xi_max = cms.double(0.20), + theta_x_mean = cms.double(0), + theta_x_sigma = cms.double(50E-6), # in rad + theta_y_mean = cms.double(0), + theta_y_sigma = cms.double(50E-6), + + nParticlesSector45 = cms.uint32(1), + nParticlesSector56 = cms.uint32(1), +) diff --git a/Validation/CTPPS/python/year_2016/simulation_levels_cff.py b/Validation/CTPPS/python/year_2016/simulation_levels_cff.py new file mode 100644 index 0000000000000..53ebfdfb08e9f --- /dev/null +++ b/Validation/CTPPS/python/year_2016/simulation_levels_cff.py @@ -0,0 +1,56 @@ +import FWCore.ParameterSet.Config as cms + +# supply beam parameters +from Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi import * + +# particle generator +from Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi import * + +# direct simulation +from Validation.CTPPS.ctppsDirectProtonSimulation_cfi import * +ctppsDirectProtonSimulation.verbosity = 0 +ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +ctppsDirectProtonSimulation.useEmpiricalApertures = False +ctppsDirectProtonSimulation.roundToPitch = True +ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +ctppsDirectProtonSimulation.produceScoringPlaneHits = False +ctppsDirectProtonSimulation.produceRecHits = True + +#---------------------------------------------------------------------------------------------------- + +def SetLevel1(): + ctppsBeamParametersESSource.vtxStddevX = 0E-4 + ctppsBeamParametersESSource.vtxStddevZ = 0 + + ctppsBeamParametersESSource.beamDivX45 = 0E-6 + ctppsBeamParametersESSource.beamDivX56 = 0E-6 + ctppsBeamParametersESSource.beamDivY45 = 0E-6 + ctppsBeamParametersESSource.beamDivY56 = 0E-6 + + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel2(): + ctppsBeamParametersESSource.beamDivX45 = 0E-6 + ctppsBeamParametersESSource.beamDivX56 = 0E-6 + ctppsBeamParametersESSource.beamDivY45 = 0E-6 + ctppsBeamParametersESSource.beamDivY56 = 0E-6 + + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel3(): + ctppsDirectProtonSimulation.roundToPitch = False + + +def SetLevel4(): + pass + +def SetLowTheta(): + process.generator.theta_x_sigma = 0E-6 + process.generator.theta_y_sigma = 0E-6 + + +def SetLargeTheta(): + pass diff --git a/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml b/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml new file mode 100644 index 0000000000000..f7a9a2f083eca --- /dev/null +++ b/Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py new file mode 100644 index 0000000000000..3b7d651922bd3 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/beam_smearing_validation/test_beam_smearing_cfg.py @@ -0,0 +1,59 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestBeamSmearing', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info and optics +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# beam-smearing validation +process.ctppsBeamSmearingValidator = cms.EDAnalyzer("CTPPSBeamSmearingValidator", + tagBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + outputFile = cms.string("test_beam_smearing.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsBeamSmearingValidator +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py new file mode 100644 index 0000000000000..3f3de6e596435 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_acceptance_cfg.py @@ -0,0 +1,98 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestAcceptance', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info and optics +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') +process.ctppsDirectProtonSimulation.verbosity = 0 +process.ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +process.ctppsDirectProtonSimulation.useEmpiricalApertures = False +process.ctppsDirectProtonSimulation.roundToPitch = True +process.ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +process.ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +process.ctppsDirectProtonSimulation.produceScoringPlaneHits = False +process.ctppsDirectProtonSimulation.produceRecHits = True + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# acceptance plotter +process.ctppsAcceptancePlotter = cms.EDAnalyzer("CTPPSAcceptancePlotter", + tagHepMC = cms.InputTag("generator", "unsmeared"), + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + + rpId_45_F = cms.uint32(3), + rpId_45_N = cms.uint32(2), + rpId_56_N = cms.uint32(102), + rpId_56_F = cms.uint32(103), + + outputFile = cms.string("test_acceptance.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsAcceptancePlotter +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py new file mode 100644 index 0000000000000..318e0360450ca --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_smearing_effects_cfg.py @@ -0,0 +1,109 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSTestAcceptance', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info and optics +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') + +process.ctppsDirectProtonSimulationSm = process.ctppsDirectProtonSimulation.clone( + verbosity = 0, + hepMCTag = cms.InputTag('beamDivergenceVtxGenerator'), + useEmpiricalApertures = False, + roundToPitch = True, + pitchStrips = 66E-3 * 12 / 19, # effective value to reproduce real RP resolution + produceHitsRelativeToBeam = True, + produceScoringPlaneHits = True, + produceRecHits = True, +) + +process.ctppsDirectProtonSimulationNoSm = process.ctppsDirectProtonSimulationSm.clone( + hepMCTag = cms.InputTag("generator", "unsmeared"), + produceScoringPlaneHits = True, + produceRecHits = False, +) + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulationSm') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# plotters +process.ctppsDirectProtonSimulationValidatorBeamSm = cms.EDAnalyzer("CTPPSDirectProtonSimulationValidator", + simuTracksTag = cms.InputTag("ctppsDirectProtonSimulationNoSm"), + recoTracksTag = cms.InputTag("ctppsDirectProtonSimulationSm"), + outputFile = cms.string("test_smearing_effects_beam.root") +) + +process.ctppsDirectProtonSimulationValidatorSensorSm = cms.EDAnalyzer("CTPPSDirectProtonSimulationValidator", + simuTracksTag = cms.InputTag("ctppsDirectProtonSimulationSm"), + recoTracksTag = cms.InputTag("ctppsLocalTrackLiteProducer"), + outputFile = cms.string("test_smearing_effects_sensor.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulationNoSm + * process.ctppsDirectProtonSimulationSm + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsDirectProtonSimulationValidatorBeamSm + * process.ctppsDirectProtonSimulationValidatorSensorSm +) diff --git a/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py new file mode 100644 index 0000000000000..56deec1684b90 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/direct_simulation_validation/test_xy_pattern_cfg.py @@ -0,0 +1,91 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSFastSimulation', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# supply LHC info and optics +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsOpticalFunctions_cff") + +# supply beam parameters +process.load("Validation.CTPPS.year_2016.ctppsBeamParametersESSource_cfi") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# fast simulation +process.load('Validation.CTPPS.ctppsDirectProtonSimulation_cfi') +process.ctppsDirectProtonSimulation.verbosity = 0 +process.ctppsDirectProtonSimulation.hepMCTag = cms.InputTag('beamDivergenceVtxGenerator') +process.ctppsDirectProtonSimulation.useEmpiricalApertures = False +process.ctppsDirectProtonSimulation.roundToPitch = True +process.ctppsDirectProtonSimulation.pitchStrips = 66E-3 * 12 / 19 # effective value to reproduce real RP resolution +process.ctppsDirectProtonSimulation.produceHitsRelativeToBeam = True +process.ctppsDirectProtonSimulation.produceScoringPlaneHits = False +process.ctppsDirectProtonSimulation.produceRecHits = True + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# distribution plotter +process.ctppsTrackDistributionPlotter = cms.EDAnalyzer("CTPPSTrackDistributionPlotter", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + outputFile = cms.string("test_xy_pattern.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsTrackDistributionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py new file mode 100644 index 0000000000000..53f998bd52e0e --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_gun_validation/test_proton_gun_cfg.py @@ -0,0 +1,51 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSFastSimulation', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# provide LHC info +# TODO: remove this line once data are available in CondDB +process.load("CalibPPS.ESProducers.ctppsLHCInfo_cff") + +# particle generator +process.load("Validation.CTPPS.year_2016.randomXiThetaGunProducer_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), +) + +# plotter +process.ctppsHepMCDistributionPlotter = cms.EDAnalyzer("CTPPSHepMCDistributionPlotter", + tagHepMC = cms.InputTag("generator", "unsmeared"), + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB + outputFile = cms.string("test_proton_gun.root") +) + +# processing path +process.p = cms.Path( + process.generator + * process.ctppsHepMCDistributionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py new file mode 100644 index 0000000000000..3ed71f5688a01 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_LHC_data/test_reconstruction_cfg.py @@ -0,0 +1,82 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process("CTPPSTestProtonReconstruction", eras.ctpps_2016) + +# declare global tag +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, "auto:run2_data") + +# TODO: these lines can be useful before all necessary data available in DB with an auto GT +#process.GlobalTag = GlobalTag(process.GlobalTag, "105X_dataRun2_relval_v2") +#process.alignmentEsPrefer = cms.ESPrefer("PoolDBESSource", "GlobalTag") + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# data source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + # more at: https://cmsweb.cern.ch/das/request?view=list&limit=50&instance=prod%2Fglobal&input=file+dataset%3D%2FBTagCSV%2FRun2016C-07Aug17-v1%2FAOD + "/store/data/Run2016C/BTagCSV/AOD/07Aug17-v1/110000/0026FCD2-369A-E711-920C-0025905A607E.root" + ), + inputCommands = cms.untracked.vstring( + "keep *", + "drop CTPPSLocalTrackLites_*_*_*" + ) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + +# load reconstruction sequences +process.load("RecoCTPPS.Configuration.recoCTPPS_cff") +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +process.ctppsProtons.verbosity = 0 + +# reconstruction validator +process.ctppsProtonReconstructionValidator = cms.EDAnalyzer("CTPPSProtonReconstructionValidator", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + tagRecoProtons = cms.InputTag("ctppsProtons", "multiRP"), + + chiSqCut = cms.double(2.), + + outputFile = cms.string("test_reconstruction_validation.root") +) + +# reconstruction plotter +process.ctppsProtonReconstructionPlotter = cms.EDAnalyzer("CTPPSProtonReconstructionPlotter", + tagTracks = cms.InputTag("ctppsLocalTrackLiteProducer"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), + + rpId_45_F = cms.uint32(3), + rpId_45_N = cms.uint32(2), + rpId_56_N = cms.uint32(102), + rpId_56_F = cms.uint32(103), + + outputFile = cms.string("test_reconstruction_plots.root") +) + +# processing sequence +process.p = cms.Path( + process.totemRPLocalReconstruction + * process.ctppsDiamondLocalReconstruction + #* process.totemTimingLocalReconstruction + #* process.ctppsPixelLocalReconstruction + * process.ctppsLocalTrackLiteProducer + * process.ctppsProtons + + * process.ctppsProtonReconstructionValidator + * process.ctppsProtonReconstructionPlotter +) diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml new file mode 100644 index 0000000000000..f2eaf3e5fe243 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/alignment_template.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple new file mode 100755 index 0000000000000..914825a93d227 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/run_multiple @@ -0,0 +1,60 @@ +#!/bin/bash + +function RunOne() +{ + local tag="$1" + local de_x_N="$2" + local de_x_F="$3" + local de_y_N="$4" + local de_y_F="$5" + + local cfgFile="${tag}_cfg.py" + local logFile="${tag}.log" + local aligFile="${tag}.xml" + + cat "alignment_template.xml" | sed "\ + s|\$de_x_N|$de_x_N|; \ + s|\$de_x_F|$de_x_F|; \ + s|\$de_y_N|$de_y_N|; \ + s|\$de_y_F|$de_y_F|; \ + " > "$dir/$aligFile" + + cp "template_cfg.py" "$dir/$cfgFile" + + ( + echo "process.maxEvents.input = $events" + + echo "process.ctppsRPAlignmentCorrectionsDataESSourceXML.MisalignedFiles += cms.vstring(\"Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/$dir/$aligFile\")" + echo "process.ctppsProtonReconstructionSimulationValidator.outputFile = \"${tag}_validation.root\"" + ) >> "$dir/$cfgFile" + + cd "$dir" + + cmsRun "$cfgFile" &> "$logFile" & + + cd - &> /dev/null +} + + +#---------------------------------------------------------------------------------------------------- + +function Run() +{ + events="$1" + dir="$2" + + rm -rf "$dir" + mkdir "$dir" + + RunOne "none" "0" "0" "0" "0" + RunOne "x_sym" "+150" "+150" "0" "0" + RunOne "x_asym" "-10" "+10" "0" "0" + RunOne "y_sym" "0" "0" "+100" "+100" + RunOne "y_asym" "0" "0" "-10" "+10" +} + +#---------------------------------------------------------------------------------------------------- + +#Run "100" "1E2" + +Run "10000" "1E4" diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py new file mode 100644 index 0000000000000..5a8940d93e4ae --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/misalignment/template_cfg.py @@ -0,0 +1,98 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSProtonReconstructionTest', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +process.load("CalibPPS.ESProducers.ctppsRPAlignmentCorrectionsDataESSourceXML_cfi") + +# beam-smearing settings +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# simulation-level settings +from Validation.CTPPS.year_2016.simulation_levels_cff import * + +process.ctppsBeamParametersESSource = ctppsBeamParametersESSource +process.generator = generator +process.ctppsDirectProtonSimulation = ctppsDirectProtonSimulation + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# proton reconstruction +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") +process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtons.fitVtxY = False + +# reconstruction validation +process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", + tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), + + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB + + outputFile = cms.string("") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsProtons + + * process.ctppsProtonReconstructionSimulationValidator +) + +#---------- + +SetLargeTheta() +SetLevel4() + diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple new file mode 100755 index 0000000000000..92740468946af --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/run_multiple @@ -0,0 +1,55 @@ +#!/bin/bash + +function RunOne() +{ + local thSize="$1" + local level="$2" + + local tag="th_${thSize}_level_${level}" + + local cfgFile="${tag}_cfg.py" + local logFile="${tag}.log" + + cp "template_cfg.py" "$dir/$cfgFile" + + ( + echo "process.maxEvents.input = $events" + echo "Set${thSize}Theta()" + echo "SetLevel${level}()" + echo "process.ctppsProtonReconstructionSimulationValidator.outputFile = \"${tag}_validation.root\"" + ) >> "$dir/$cfgFile" + + cd "$dir" + + cmsRun "$cfgFile" &> "$logFile" & + + cd - &> /dev/null +} + + +#---------------------------------------------------------------------------------------------------- + +function Run() +{ + events="$1" + dir="$2" + + rm -rf "$dir" + mkdir "$dir" + + #RunOne "Low" "1" + #RunOne "Low" "2" + #RunOne "Low" "3" + #RunOne "Low" "4" + + RunOne "Large" "1" + RunOne "Large" "2" + RunOne "Large" "3" + RunOne "Large" "4" +} + +#---------------------------------------------------------------------------------------------------- + +#Run "100" "1E2" + +Run "10000" "1E4" diff --git a/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py new file mode 100644 index 0000000000000..5071bff810342 --- /dev/null +++ b/Validation/CTPPS/test/year_2016/proton_reconstruction_MC/resolution/template_cfg.py @@ -0,0 +1,93 @@ +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras +process = cms.Process('CTPPSProtonReconstructionTest', eras.ctpps_2016) + +# minimal logger settings +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cerr'), + cerr = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# number of events +process.source = cms.Source("EmptySource", + firstRun = cms.untracked.uint32(280000) +) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10) +) + +# particle-data table +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") + +# random seeds +process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService", + sourceSeed = cms.PSet(initialSeed =cms.untracked.uint32(98765)), + generator = cms.PSet(initialSeed = cms.untracked.uint32(98766)), + beamDivergenceVtxGenerator = cms.PSet(initialSeed =cms.untracked.uint32(3849)) +) + +# geometry +process.load("Geometry.VeryForwardGeometry.geometryRPFromDD_2017_cfi") +del(process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles[-1]) +process.XMLIdealGeometryESSource_CTPPS.geomXMLFiles.append("Validation/CTPPS/test/year_2016/RP_Dist_Beam_Cent.xml") + +# beam-smearing settings +process.load("IOMC.EventVertexGenerators.beamDivergenceVtxGenerator_cfi") + +# simulation-level settings +from Validation.CTPPS.year_2016.simulation_levels_cff import * + +process.ctppsBeamParametersESSource = ctppsBeamParametersESSource +process.generator = generator +process.ctppsDirectProtonSimulation = ctppsDirectProtonSimulation + +# strips reco +process.load('RecoCTPPS.TotemRPLocal.totemRPUVPatternFinder_cfi') +process.totemRPUVPatternFinder.tagRecHit = cms.InputTag('ctppsDirectProtonSimulation') + +process.load('RecoCTPPS.TotemRPLocal.totemRPLocalTrackFitter_cfi') + +# common reco: lite track production +process.load('RecoCTPPS.TotemRPLocal.ctppsLocalTrackLiteProducer_cff') +process.ctppsLocalTrackLiteProducer.includeDiamonds = False +process.ctppsLocalTrackLiteProducer.includePixels = False + +# proton reconstruction +process.load("RecoCTPPS.ProtonReconstruction.ctppsProtons_cff") +process.ctppsProtons.tagLocalTrackLite = cms.InputTag('ctppsLocalTrackLiteProducer') +#process.ctppsProtons.fitVtxY = False + +# reconstruction validation +process.ctppsProtonReconstructionSimulationValidator = cms.EDAnalyzer("CTPPSProtonReconstructionSimulationValidator", + tagHepMCBeforeSmearing = cms.InputTag("generator", "unsmeared"), + tagHepMCAfterSmearing = cms.InputTag("beamDivergenceVtxGenerator"), + tagRecoProtonsSingleRP = cms.InputTag("ctppsProtons", "singleRP"), + tagRecoProtonsMultiRP = cms.InputTag("ctppsProtons", "multiRP"), + + lhcInfoLabel = process.ctppsLHCInfoESSource_2016.label, # TODO: replace with "" once data loaded from DB + + outputFile = cms.string("") +) + +# processing path +process.p = cms.Path( + process.generator + * process.beamDivergenceVtxGenerator + * process.ctppsDirectProtonSimulation + + * process.totemRPUVPatternFinder + * process.totemRPLocalTrackFitter + * process.ctppsLocalTrackLiteProducer + + * process.ctppsProtons + + * process.ctppsProtonReconstructionSimulationValidator +) + +#---------- + diff --git a/Validation/Configuration/python/autoValidation.py b/Validation/Configuration/python/autoValidation.py index 65263d1a1a1d2..39ebc1c4b567e 100644 --- a/Validation/Configuration/python/autoValidation.py +++ b/Validation/Configuration/python/autoValidation.py @@ -10,7 +10,7 @@ 'miniAODValidation' : ['prevalidationMiniAOD','validationMiniAOD','validationHarvestingMiniAOD'], 'standardValidation' : ['prevalidation','validation','validationHarvesting'], 'standardValidationNoHLT' : ['prevalidationNoHLT','validationNoHLT','validationHarvestingNoHLT'], - 'HGCalValidation' : ['', 'globalValidationHGCal', ''], + 'HGCalValidation' : ['', 'globalValidationHGCal', 'hgcalValidatorPostProcessor'], 'OuterTrackerValidation' : ['', 'globalValidationOuterTracker', 'postValidationOuterTracker'], } diff --git a/Validation/Configuration/python/hgcalSimValid_cff.py b/Validation/Configuration/python/hgcalSimValid_cff.py index bd5e8899be269..fe1b8a7335e46 100644 --- a/Validation/Configuration/python/hgcalSimValid_cff.py +++ b/Validation/Configuration/python/hgcalSimValid_cff.py @@ -5,6 +5,10 @@ from Validation.HGCalValidation.rechitValidation_cff import * from Validation.HGCalValidation.hgcalHitValidation_cfi import * +from Validation.HGCalValidation.HGCalValidator_cfi import hgcalValidator + +hgcalValidatorSequence = cms.Sequence(hgcalValidator) + hgcalValidation = cms.Sequence(hgcalSimHitValidationEE + hgcalSimHitValidationHEF + hgcalSimHitValidationHEB @@ -14,4 +18,5 @@ + hgcalRecHitValidationEE + hgcalRecHitValidationHEF + hgcalRecHitValidationHEB - + hgcalHitValidationSequence) + + hgcalHitValidationSequence + + hgcalValidatorSequence) diff --git a/Validation/GlobalRecHits/src/GlobalRecHitsAnalyzer.cc b/Validation/GlobalRecHits/src/GlobalRecHitsAnalyzer.cc index 1a77fca2cd90c..2b72591c6d85d 100644 --- a/Validation/GlobalRecHits/src/GlobalRecHitsAnalyzer.cc +++ b/Validation/GlobalRecHits/src/GlobalRecHitsAnalyzer.cc @@ -600,9 +600,6 @@ void GlobalRecHitsAnalyzer::fillHCal(const edm::Event& iEvent, return; } - // iterator to access containers - edm::PCaloHitContainer::const_iterator itHit; - /////////////////////// // extract simhit info ////////////////////// diff --git a/Validation/HGCalValidation/BuildFile.xml b/Validation/HGCalValidation/BuildFile.xml new file mode 100644 index 0000000000000..800c4cb6503c9 --- /dev/null +++ b/Validation/HGCalValidation/BuildFile.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Validation/HGCalValidation/data/D28.cumulative.xo b/Validation/HGCalValidation/data/D28.cumulative.xo new file mode 100644 index 0000000000000..5609de7526b0f --- /dev/null +++ b/Validation/HGCalValidation/data/D28.cumulative.xo @@ -0,0 +1,52 @@ +1.0 0.434 +2.0 1.402 +3.0 2.273 +4.0 3.241 +5.0 4.112 +6.0 5.08 +7.0 5.951 +8.0 6.919 +9.0 7.79 +10.0 8.758 +11.0 9.629 +12.0 10.597 +13.0 11.468 +14.0 12.436 +15.0 13.307 +16.0 14.275 +17.0 15.146 +18.0 16.114 +19.0 16.985 +20.0 17.953 +21.0 18.824 +22.0 19.792 +23.0 20.663 +24.0 21.631 +25.0 22.502 +26.0 23.47 +27.0 24.341 +28.0 25.309 +29.0 27.793 +30.0 30.324 +31.0 32.856 +32.0 35.387 +33.0 37.919 +34.0 40.45 +35.0 42.982 +36.0 45.513 +37.0 48.045 +38.0 50.576 +39.0 53.108 +40.0 55.639 +41.0 60.072 +42.0 64.505 +43.0 68.969 +44.0 73.44 +45.0 77.912 +46.0 82.383 +47.0 86.854 +48.0 91.325 +49.0 95.797 +50.0 100.268 +51.0 104.739 +52.0 109.211 diff --git a/Validation/HGCalValidation/interface/CaloParticleSelector.h b/Validation/HGCalValidation/interface/CaloParticleSelector.h new file mode 100755 index 0000000000000..5f288c2eba79f --- /dev/null +++ b/Validation/HGCalValidation/interface/CaloParticleSelector.h @@ -0,0 +1,133 @@ +#ifndef Validation_HGCalValidation_CaloParticleSelector_h +#define Validation_HGCalValidation_CaloParticleSelector_h +/* \class CaloParticleSelector + * + * \author Giuseppe Cerati, INFN + * + * $Date: 2013/05/14 15:46:46 $ + * $Revision: 1.5.4.2 $ + * + */ +#include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/Math/interface/PtEtaPhiMass.h" +#include "DataFormats/Math/interface/deltaPhi.h" + +class CaloParticleSelector { + + public: + CaloParticleSelector(){} + CaloParticleSelector ( double ptMin, double ptMax, double minRapidity,double maxRapidity, double lip, double tip, + int minHit, bool signalOnly, bool intimeOnly, bool chargedOnly, bool stableOnly, + const std::vector& pdgId = std::vector(), + double minPhi=-3.2, double maxPhi=3.2) : + ptMin2_( ptMin*ptMin ), ptMax2_( ptMax*ptMax ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ), lip_( lip ), tip2_( tip*tip ), meanPhi_((minPhi+maxPhi)/2.), rangePhi_((maxPhi-minPhi)/2.), minHit_( minHit ), signalOnly_(signalOnly), intimeOnly_(intimeOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) { + if(minPhi >= maxPhi) { + throw cms::Exception("Configuration") << "CaloParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi << "). The range is constructed from minPhi to maxPhi around their average."; + } + if(minPhi >= M_PI) { + throw cms::Exception("Configuration") << "CaloParticleSelector: minPhi (" << minPhi << ") must be smaller than PI. The range is constructed from minPhi to maxPhi around their average."; + } + if(maxPhi <= -M_PI) { + throw cms::Exception("Configuration") << "CaloParticleSelector: maxPhi (" << maxPhi << ") must be larger than -PI. The range is constructed from minPhi to maxPhi around their average."; + } + } + + // Operator() performs the selection: e.g. if (cPSelector(cp)) {...} + // For the moment there shouldn't be any SimTracks from different crossings in the CaloParticle. + bool operator()( const CaloParticle & tp , std::vector const & simVertices) const { + // signal only means no PU particles + if (signalOnly_ && !(tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0)) return false; + // intime only means no OOT PU particles + if (intimeOnly_ && !(tp.eventId().bunchCrossing()==0)) return false; + + auto pdgid = tp.pdgId(); + if(!pdgId_.empty()) { + bool testId = false; + for(auto id: pdgId_) { + if(id == pdgid) { testId = true; break;} + } + if(!testId) return false; + } + + if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0 + + // select only stable particles + if (stableOnly_) { + for( CaloParticle::genp_iterator j = tp.genParticle_begin(); j != tp.genParticle_end(); ++ j ) { + if (j->get()==nullptr || j->get()->status() != 1) { + return false; + } + } + + // test for remaining unstabled due to lack of genparticle pointer + std::vector pdgids {11,13,211,321,2212,3112,3222,3312,3334}; + if( tp.status() == -99 && + (!std::binary_search(pdgids.begin(), pdgids.end(), std::abs(pdgid) )) + ){ return false; } + } + + auto etaOk = [&](const CaloParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);}; + auto phiOk = [&](const CaloParticle& p) { float dphi = deltaPhi(atan2f(p.py(),p.px()), meanPhi_); return dphi >= -rangePhi_ && dphi <= rangePhi_; }; + auto ptOk = [&](const CaloParticle& p) { double pt2 = tp.p4().perp2(); return pt2 >= ptMin2_ && pt2 <= ptMax2_; }; + + return ( + ptOk(tp) && + etaOk(tp) && + phiOk(tp) + ); + } + + private: + double ptMin2_; + double ptMax2_; + float minRapidity_; + float maxRapidity_; + double lip_; + double tip2_; + float meanPhi_; + float rangePhi_; + int minHit_; + bool signalOnly_; + bool intimeOnly_; + bool chargedOnly_; + bool stableOnly_; + std::vector pdgId_; +}; + +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h" + +namespace reco { + namespace modules { + + template<> + struct ParameterAdapter { + static CaloParticleSelector make( const edm::ParameterSet & cfg, edm::ConsumesCollector & iC ) { + return make(cfg); + } + + static CaloParticleSelector make( const edm::ParameterSet & cfg) { + return CaloParticleSelector( + cfg.getParameter( "ptMin" ), + cfg.getParameter( "ptMax" ), + cfg.getParameter( "minRapidity" ), + cfg.getParameter( "maxRapidity" ), + cfg.getParameter( "lip" ), + cfg.getParameter( "tip" ), + cfg.getParameter( "minHit" ), + cfg.getParameter( "signalOnly" ), + cfg.getParameter( "intimeOnly" ), + cfg.getParameter( "chargedOnly" ), + cfg.getParameter( "stableOnly" ), + cfg.getParameter >( "pdgId" ), + cfg.getParameter( "minPhi" ), + cfg.getParameter( "maxPhi" )); + } + }; + + } +} + +#endif diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h new file mode 100644 index 0000000000000..5fc34b8b5c8d2 --- /dev/null +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -0,0 +1,91 @@ +#ifndef HGCalValidator_h +#define HGCalValidator_h + +/** \class HGCalValidator + * Class that produces histograms to validate HGCal Reconstruction performances + * + * \author HGCal + */ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" + +#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" +#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" +#include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" + +#include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h" + +#include "Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h" +#include "Validation/HGCalValidation/interface/CaloParticleSelector.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" + +class PileupSummaryInfo; + +struct HGCalValidatorHistograms { + HGVHistoProducerAlgoHistograms histoProducerAlgo; + std::vector h_layerclusters_coll; +}; + +class HGCalValidator : public DQMGlobalEDAnalyzer { + public: + using Histograms = HGCalValidatorHistograms; + + /// Constructor + HGCalValidator(const edm::ParameterSet& pset); + + /// Destructor + ~HGCalValidator() override; + + + /// Method called once per event + void dqmAnalyze(const edm::Event&, const edm::EventSetup&, const Histograms& ) const override; + /// Method called to book the DQM histograms + void bookHistograms(DQMStore::ConcurrentBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override; + + void cpParametersAndSelection(const Histograms& histograms, std::vector const & cPeff, std::vector const & simVertices, std::vector& selected_cPeff) const; + + + protected: + + std::vector label; + const bool SaveGeneralInfo_; + const bool doCaloParticlePlots_; + const bool dolayerclustersPlots_; + const edm::FileInPath cummatbudinxo_; + + std::vector > labelToken; + edm::EDGetTokenT > label_cp_effic; + edm::EDGetTokenT > label_cp_fake; + edm::EDGetTokenT > simVertices_; + edm::EDGetTokenT recHitsEE_; + edm::EDGetTokenT recHitsFH_; + edm::EDGetTokenT recHitsBH_; + edm::EDGetTokenT density_; + std::unique_ptr histoProducerAlgo_; + + + + private: + + void fillHitMap(std::map &, + const HGCRecHitCollection &, + const HGCRecHitCollection &, + const HGCRecHitCollection &) const; + CaloParticleSelector cpSelector; + std::shared_ptr tools_; + std::map cummatbudg; + std::vector particles_to_monitor_; + unsigned totallayers_to_monitor_; + std::vector thicknesses_to_monitor_; + std::string dirName_; +}; + + +#endif diff --git a/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h new file mode 100644 index 0000000000000..d2cc1bd448108 --- /dev/null +++ b/Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h @@ -0,0 +1,186 @@ +#ifndef Validation_HGCalValidation_HGVHistoProducerAlgo_h +#define Validation_HGCalValidation_HGVHistoProducerAlgo_h + +/* \author HGCal + */ + +#include +#include +#include +#include + +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" +#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" +#include "DataFormats/HGCRecHit/interface/HGCRecHit.h" + +#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" +#include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" +#include "SimDataFormats/Vertex/interface/SimVertex.h" +#include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalImagingAlgo.h" + +#include "DQMServices/Core/interface/DQMStore.h" +#include "DQMServices/Core/interface/ConcurrentMonitorElement.h" + +struct HGVHistoProducerAlgoHistograms { + //Info + //To be able to spot any issues both in -z and +z a layer id was introduced + //that spans from 0 to 103 for hgcal_v9 geometry. The mapping for hgcal_v9 is: + //-z: 0->51 + //+z: 52->103 + //We will pick the numbers below from RecHitTools just to avoid future problems + ConcurrentMonitorElement lastLayerEEzm; // last layer of EE -z + ConcurrentMonitorElement lastLayerFHzm; // last layer of FH -z + ConcurrentMonitorElement maxlayerzm; // last layer of BH -z + ConcurrentMonitorElement lastLayerEEzp; // last layer of EE +z + ConcurrentMonitorElement lastLayerFHzp; // last layer of FH +z + ConcurrentMonitorElement maxlayerzp; // last layer of BH +z + + //1D + std::vector h_cluster_eta; + std::vector h_mixedhitscluster_zminus; + std::vector h_mixedhitscluster_zplus; + std::vector h_energyclustered_zminus; + std::vector h_energyclustered_zplus; + std::vector h_longdepthbarycentre_zminus; + std::vector h_longdepthbarycentre_zplus; + + std::unordered_map h_clusternum_perlayer; + std::unordered_map h_energyclustered_perlayer; + std::unordered_map h_score_layercl2caloparticle_perlayer; + std::unordered_map h_score_caloparticle2layercl_perlayer; + std::unordered_map h_energy_vs_score_caloparticle2layercl_perlayer; + std::unordered_map h_energy_vs_score_layercl2caloparticle_perlayer; + std::unordered_map h_sharedenergy_caloparticle2layercl_perlayer; + std::unordered_map h_sharedenergy_caloparticle2layercl_vs_eta_perlayer; + std::unordered_map h_sharedenergy_caloparticle2layercl_vs_phi_perlayer; + std::unordered_map h_sharedenergy_layercl2caloparticle_perlayer; + std::unordered_map h_sharedenergy_layercl2caloparticle_vs_eta_perlayer; + std::unordered_map h_sharedenergy_layercl2caloparticle_vs_phi_perlayer; + std::unordered_map h_num_caloparticle_eta_perlayer; + std::unordered_map h_numDup_caloparticle_eta_perlayer; + std::unordered_map h_denom_caloparticle_eta_perlayer; + std::unordered_map h_num_caloparticle_phi_perlayer; + std::unordered_map h_numDup_caloparticle_phi_perlayer; + std::unordered_map h_denom_caloparticle_phi_perlayer; + std::unordered_map h_num_layercl_eta_perlayer; + std::unordered_map h_numMerge_layercl_eta_perlayer; + std::unordered_map h_denom_layercl_eta_perlayer; + std::unordered_map h_num_layercl_phi_perlayer; + std::unordered_map h_numMerge_layercl_phi_perlayer; + std::unordered_map h_denom_layercl_phi_perlayer; + std::unordered_map h_cellAssociation_perlayer; + std::unordered_map h_clusternum_perthick; + std::unordered_map h_cellsenedens_perthick; + + std::unordered_map< std::string, ConcurrentMonitorElement > h_cellsnum_perthickperlayer; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetoseedcell_perthickperlayer_eneweighted; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancetomaxcell_perthickperlayer_eneweighted; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcell_perthickperlayer; + std::unordered_map< std::string, ConcurrentMonitorElement > h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer; + + std::unordered_map h_caloparticle_eta; + std::unordered_map h_caloparticle_eta_Zorigin; + std::unordered_map h_caloparticle_energy; + std::unordered_map h_caloparticle_pt; + std::unordered_map h_caloparticle_phi; + +}; + +class HGVHistoProducerAlgo { + public: + HGVHistoProducerAlgo(const edm::ParameterSet& pset) ; + ~HGVHistoProducerAlgo(); + + using Histograms = HGVHistoProducerAlgoHistograms; + + void bookInfo(DQMStore::ConcurrentBooker& ibook, Histograms& histograms); + void bookCaloParticleHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,int pdgid); + + void bookClusterHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,unsigned layers, + std::vector thicknesses, std::string pathtomatbudfile); + void layerClusters_to_CaloParticles(const Histograms& histograms, + const reco::CaloClusterCollection &clusters, + std::vector const & cP, + std::map const &, + unsigned layers) const ; + void fill_info_histos(const Histograms& histograms, unsigned layers) const; + void fill_caloparticle_histos(const Histograms& histograms, + int pdgid, + const CaloParticle & caloparticle, + std::vector const & simVertices) const ; + + void fill_cluster_histos(const Histograms& histograms, + int count, + const reco::CaloCluster & cluster) const; + + void fill_generic_cluster_histos(const Histograms& histograms, + int count, + const reco::CaloClusterCollection &clusters, + const Density &densities, + std::vector const & cP, + std::map const &, + std::map cummatbudg, + unsigned layers, + std::vector thicknesses) const ; + + double distance2(const double x1, const double y1, const double x2, const double y2) const; + double distance(const double x1, const double y1, const double x2, const double y2) const; + + void setRecHitTools(std::shared_ptr recHitTools ); + + DetId findmaxhit(const reco::CaloCluster & cluster, + std::map const &) const; + + struct detIdInfoInCluster + { + bool operator==(const detIdInfoInCluster& o) const { return clusterId == o.clusterId;}; + unsigned int clusterId; + float fraction; + }; + + struct caloParticleOnLayer + { + unsigned int caloParticleId; + float energy=0; + std::vector > hits_and_fractions; + std::unordered_map> layerClusterIdToEnergyAndScore; + }; + private: + + double getEta(double eta) const; + + std::shared_ptr recHitTools_; + + //private data members + double minEta_, maxEta_; int nintEta_; bool useFabsEta_; + double minEne_, maxEne_; int nintEne_; + double minPt_, maxPt_; int nintPt_; + double minPhi_, maxPhi_; int nintPhi_; + double minMixedHitsCluster_, maxMixedHitsCluster_; int nintMixedHitsCluster_; + double minEneCl_, maxEneCl_; int nintEneCl_; + double minLongDepBary_, maxLongDepBary_; int nintLongDepBary_; + double minZpos_, maxZpos_; int nintZpos_; + double minTotNClsperlay_, maxTotNClsperlay_; int nintTotNClsperlay_; + double minEneClperlay_, maxEneClperlay_; int nintEneClperlay_; + double minScore_, maxScore_; int nintScore_; + double minSharedEneFrac_,maxSharedEneFrac_; int nintSharedEneFrac_; + double minTotNClsperthick_, maxTotNClsperthick_; int nintTotNClsperthick_; + double minTotNcellsperthickperlayer_, maxTotNcellsperthickperlayer_; int nintTotNcellsperthickperlayer_; + double minDisToSeedperthickperlayer_, maxDisToSeedperthickperlayer_; int nintDisToSeedperthickperlayer_; + double minDisToSeedperthickperlayerenewei_, maxDisToSeedperthickperlayerenewei_; int nintDisToSeedperthickperlayerenewei_; + double minDisToMaxperthickperlayer_, maxDisToMaxperthickperlayer_; int nintDisToMaxperthickperlayer_; + double minDisToMaxperthickperlayerenewei_, maxDisToMaxperthickperlayerenewei_; int nintDisToMaxperthickperlayerenewei_; + double minDisSeedToMaxperthickperlayer_, maxDisSeedToMaxperthickperlayer_; int nintDisSeedToMaxperthickperlayer_; + double minClEneperthickperlayer_, maxClEneperthickperlayer_; int nintClEneperthickperlayer_; + double minCellsEneDensperthick_, maxCellsEneDensperthick_; int nintCellsEneDensperthick_; + +}; + +#endif diff --git a/Validation/HGCalValidation/plugins/BuildFile.xml b/Validation/HGCalValidation/plugins/BuildFile.xml index 7dcf1842b8a30..136cda9a4b113 100644 --- a/Validation/HGCalValidation/plugins/BuildFile.xml +++ b/Validation/HGCalValidation/plugins/BuildFile.xml @@ -29,6 +29,7 @@ + diff --git a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc index 8e67733b87247..a8a1b4344079f 100644 --- a/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalDigiValidation.cc @@ -59,9 +59,11 @@ class HGCalDigiValidation : public DQMEDAnalyzer { digiInfo() { x = y = z = charge = 0.0; layer = adc = 0; + mode = threshold = false; } double x, y, z, charge; int layer, adc; + bool mode, threshold; //tot mode and zero supression }; explicit HGCalDigiValidation(const edm::ParameterSet&); @@ -78,7 +80,7 @@ class HGCalDigiValidation : public DQMEDAnalyzer { void fillOccupancyMap(std::map& OccupancyMap, int layer); template void digiValidation(const T1& detId, const T2* geom, int layer, - uint16_t adc, double charge); + uint16_t adc, double charge, bool mode, bool threshold); // ----------member data --------------------------- std::string nameDetector_; @@ -90,9 +92,10 @@ class HGCalDigiValidation : public DQMEDAnalyzer { std::map OccupancyMap_plus_; std::map OccupancyMap_minus_; - std::vector charge_; + std::vector TOA_; std::vector DigiOccupancy_XY_; std::vector ADC_; + std::vector TOT_; std::vector DigiOccupancy_Plus_; std::vector DigiOccupancy_Minus_; MonitorElement* MeanDigiOccupancy_Plus_; @@ -132,7 +135,7 @@ void HGCalDigiValidation::fillDescriptions(edm::ConfigurationDescriptions& descr desc.add("ifNose",false); desc.add("ifHCAL",false); desc.addUntracked("Verbosity",0); - desc.addUntracked("SampleIndx",0); + desc.addUntracked("SampleIndx",2); // central bx descriptions.add("hgcalDigiValidationEEDefault",desc); } @@ -188,8 +191,10 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom0, layer, adc, charge); + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom0, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -215,8 +220,10 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom0, layer, adc, charge); + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom0, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -239,8 +246,10 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, const HGCSample& hgcSample = it.sample(SampleIndx_); uint16_t gain = hgcSample.toa(); uint16_t adc = hgcSample.data(); - double charge = adc*gain; - digiValidation(detId, geom1, layer, adc, charge); + double charge = gain; + bool totmode = hgcSample.mode(); + bool zerothreshold = hgcSample.threshold(); + digiValidation(detId, geom1, layer, adc, charge, totmode, zerothreshold); } fillDigiInfo(); } else { @@ -271,11 +280,13 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, HcalCoderDb coder(*channelCoder, *shape); CaloSamples tool; coder.adc2fC(df, tool); - int layer = detId.depth(); - uint16_t adc = (df)[SampleIndx_].adc(); - int capid = (df)[SampleIndx_].capid(); - double charge = (tool[SampleIndx_] - calibrations.pedestal(capid)); - digiValidation(detId, geom1, layer, adc, charge); + int layer = detId.depth(); + uint16_t adc = (df)[SampleIndx_].adc(); + int capid = (df)[SampleIndx_].capid(); + double charge = (tool[SampleIndx_] - calibrations.pedestal(capid)); + bool totmode = false; + bool zerothreshold = false; + digiValidation(detId, geom1, layer, adc, charge, totmode, zerothreshold); } } fillDigiInfo(); @@ -287,7 +298,7 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, edm::LogWarning("HGCalValidation") << "invalid detector name !! " << nameDetector_; } - if (verbosity_>0) + if (verbosity_>0) edm::LogVerbatim("HGCalValidation") << "Event " << iEvent.id().event() << " with " << ntot << " total and " << nused << " used digis"; @@ -296,35 +307,38 @@ void HGCalDigiValidation::analyze(const edm::Event& iEvent, template void HGCalDigiValidation::digiValidation(const T1& detId, const T2* geom, int layer, uint16_t adc, - double charge) { + double charge, bool mode, bool threshold) { if (verbosity_>1) edm::LogVerbatim("HGCalValidation") << std::hex << detId.rawId() - << std::dec; + << std::dec + << " " << detId.rawId(); DetId id1 = DetId(detId.rawId()); const GlobalPoint& global1 = geom->getPosition(id1); if (verbosity_>1) - edm::LogVerbatim("HGCalValidation") << " adc = " << adc - << " charge = " << charge; + edm::LogVerbatim("HGCalValidation") << " adc = " << adc + << " toa = " << charge; digiInfo hinfo; - hinfo.x = global1.x(); - hinfo.y = global1.y(); - hinfo.z = global1.z(); - hinfo.adc = adc; - hinfo.charge = charge; - hinfo.layer = layer-firstLayer_; + hinfo.x = global1.x(); + hinfo.y = global1.y(); + hinfo.z = global1.z(); + hinfo.adc = adc; + hinfo.charge = charge; + hinfo.layer = layer-firstLayer_; + hinfo.mode = mode; + hinfo.threshold = threshold; if (verbosity_>1) edm::LogVerbatim("HGCalValidation") << "gx = " << hinfo.x << " gy = " << hinfo.y << " gz = " << hinfo.z; - - fillDigiInfo(hinfo); if (global1.eta() > 0) fillOccupancyMap(OccupancyMap_plus_, hinfo.layer); else fillOccupancyMap(OccupancyMap_minus_, hinfo.layer); + + fillDigiInfo(hinfo); } @@ -336,9 +350,16 @@ void HGCalDigiValidation::fillOccupancyMap(std::map& OccupancyMap, void HGCalDigiValidation::fillDigiInfo(digiInfo& hinfo) { int ilayer = hinfo.layer; - charge_.at(ilayer)->Fill(hinfo.charge); - DigiOccupancy_XY_.at(ilayer)->Fill(hinfo.x, hinfo.y); - ADC_.at(ilayer)->Fill(hinfo.adc); + TOA_.at(ilayer)->Fill(hinfo.charge); + + if (hinfo.mode) { + TOT_.at(ilayer)->Fill(hinfo.adc); + } + + if (!hinfo.mode && hinfo.threshold) { + ADC_.at(ilayer)->Fill(hinfo.adc); + DigiOccupancy_XY_.at(ilayer)->Fill(hinfo.x, hinfo.y); + } } void HGCalDigiValidation::fillDigiInfo() { @@ -386,11 +407,14 @@ void HGCalDigiValidation::bookHistograms(DQMStore::IBooker& iB, std::ostringstream histoname; for (int il = 0; il < layers_; ++il) { int ilayer = firstLayer_ + il; - histoname.str(""); histoname << "charge_"<< "layer_" << ilayer; - charge_.push_back(iB.book1D(histoname.str().c_str(),"charge_",100,-25,25)); + histoname.str(""); histoname << "TOA_"<< "layer_" << ilayer; + TOA_.push_back(iB.book1D(histoname.str().c_str(),"toa_",1024,0,1024)); histoname.str(""); histoname << "ADC_" << "layer_" << ilayer; - ADC_.push_back(iB.book1D(histoname.str().c_str(), "DigiOccupancy",200,0,1000)); + ADC_.push_back(iB.book1D(histoname.str().c_str(), "ADCDigiOccupancy",1024,0,1024)); + + histoname.str(""); histoname << "TOT_" << "layer_" << ilayer; + TOT_.push_back(iB.book1D(histoname.str().c_str(), "TOTDigiOccupancy",4096,0,4096)); histoname.str(""); histoname << "DigiOccupancy_XY_" << "layer_" << ilayer; DigiOccupancy_XY_.push_back(iB.book2D(histoname.str().c_str(), "DigiOccupancy", 50, -500, 500, 50, -500, 500)); diff --git a/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc b/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc index a2f7d2affd0ea..0b26e00e8649e 100644 --- a/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc +++ b/Validation/HGCalValidation/plugins/HGCalRecHitValidation.cc @@ -324,7 +324,7 @@ void HGCalRecHitValidation::bookHistograms(DQMStore::IBooker& iB, EtaPhi_Minus_.push_back(iB.book2D(histoname.str().c_str(), "Occupancy", 31, -3.0, -1.45, 72, -CLHEP::pi, CLHEP::pi)); histoname.str(""); histoname << "energy_layer_" << ilayer; - energy_.push_back(iB.book1D(histoname.str().c_str(),"energy_",100,0,0.002)); + energy_.push_back(iB.book1D(histoname.str().c_str(),"energy_",500,0,1)); }//loop over layers ends here histoname.str(""); histoname << "SUMOfRecHitOccupancy_Plus"; diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc new file mode 100755 index 0000000000000..a958e89b6eeb7 --- /dev/null +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -0,0 +1,240 @@ +#include "Validation/HGCalValidation/interface/HGCalValidator.h" + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +using namespace std; +using namespace edm; + +HGCalValidator::HGCalValidator(const edm::ParameterSet& pset): + label(pset.getParameter< std::vector >("label")), + SaveGeneralInfo_(pset.getUntrackedParameter("SaveGeneralInfo")), + doCaloParticlePlots_(pset.getUntrackedParameter("doCaloParticlePlots")), + dolayerclustersPlots_(pset.getUntrackedParameter("dolayerclustersPlots")), + cummatbudinxo_(pset.getParameter("cummatbudinxo")) +{ + + //In this way we can easily generalize to associations between other objects also. + const edm::InputTag& label_cp_effic_tag = pset.getParameter< edm::InputTag >("label_cp_effic"); + const edm::InputTag& label_cp_fake_tag = pset.getParameter< edm::InputTag >("label_cp_fake"); + + label_cp_effic = consumes >(label_cp_effic_tag); + label_cp_fake = consumes >(label_cp_fake_tag); + + simVertices_ = consumes>(pset.getParameter("simVertices")); + + recHitsEE_ = consumes(edm::InputTag("HGCalRecHit", "HGCEERecHits")); + recHitsFH_ = consumes(edm::InputTag("HGCalRecHit", "HGCHEFRecHits")); + recHitsBH_ = consumes(edm::InputTag("HGCalRecHit", "HGCHEBRecHits")); + + density_ = consumes(edm::InputTag("hgcalLayerClusters")); + + for (auto& itag : label) { + labelToken.push_back(consumes(itag)); + } + + cpSelector = CaloParticleSelector(pset.getParameter("ptMinCP"), + pset.getParameter("ptMaxCP"), + pset.getParameter("minRapidityCP"), + pset.getParameter("maxRapidityCP"), + pset.getParameter("minHitCP"), + pset.getParameter("tipCP"), + pset.getParameter("lipCP"), + pset.getParameter("signalOnlyCP"), + pset.getParameter("intimeOnlyCP"), + pset.getParameter("chargedOnlyCP"), + pset.getParameter("stableOnlyCP"), + pset.getParameter >("pdgIdCP")); + + tools_.reset(new hgcal::RecHitTools()); + + particles_to_monitor_ = pset.getParameter >("pdgIdCP"); + totallayers_to_monitor_ = pset.getParameter("totallayers_to_monitor"); + thicknesses_to_monitor_ = pset.getParameter >("thicknesses_to_monitor"); + + //For the material budget file here + std::ifstream fmb(cummatbudinxo_.fullPath().c_str()); + double thelay = 0.; double mbg = 0.; + for (unsigned ilayer = 1; ilayer <= totallayers_to_monitor_; ++ilayer) { + fmb >> thelay >> mbg; + cummatbudg.insert( std::pair( thelay , mbg ) ); + } + + fmb.close(); + + + + ParameterSet psetForHistoProducerAlgo = pset.getParameter("histoProducerAlgoBlock"); + histoProducerAlgo_ = std::make_unique(psetForHistoProducerAlgo); + + dirName_ = pset.getParameter("dirName"); + +} + + +HGCalValidator::~HGCalValidator() {} + + +void HGCalValidator::bookHistograms(DQMStore::ConcurrentBooker& ibook, edm::Run const&, edm::EventSetup const& setup, Histograms& histograms) const { + + if (SaveGeneralInfo_){ + ibook.cd(); + ibook.setCurrentFolder(dirName_ + "GeneralInfo"); + histoProducerAlgo_->bookInfo(ibook, histograms.histoProducerAlgo); + } + + if(doCaloParticlePlots_) { + ibook.cd(); + + for (auto const particle : particles_to_monitor_) { + ibook.setCurrentFolder(dirName_ + "SelectedCaloParticles/" + std::to_string(particle)); + histoProducerAlgo_->bookCaloParticleHistos(ibook, histograms.histoProducerAlgo, particle); + } + ibook.cd(); + ibook.setCurrentFolder(dirName_); + } + + for (unsigned int www=0;wwwbookClusterHistos(ibook, histograms.histoProducerAlgo, totallayers_to_monitor_, thicknesses_to_monitor_, cummatbudinxo_.fullPath() ); + } + + }//end loop www +} + +void HGCalValidator::cpParametersAndSelection(const Histograms& histograms, + std::vector const & cPeff, + std::vector const & simVertices, + std::vector& selected_cPeff) const { + selected_cPeff.reserve(cPeff.size()); + + size_t j=0; + for (auto const caloParticle : cPeff) { + int id = caloParticle.pdgId(); + + if(cpSelector(caloParticle,simVertices)) { + selected_cPeff.push_back(j); + if(doCaloParticlePlots_) { + histoProducerAlgo_->fill_caloparticle_histos(histograms.histoProducerAlgo,id,caloParticle,simVertices); + } + } + ++j; + }//end of loop over caloparticles + +} + +void HGCalValidator::dqmAnalyze(const edm::Event& event, const edm::EventSetup& setup, const Histograms& histograms) const { + using namespace reco; + + LogDebug("HGCalValidator") << "\n====================================================" << "\n" + << "Analyzing new event" << "\n" + << "====================================================\n" << "\n"; + + edm::Handle> simVerticesHandle; + event.getByToken(simVertices_, simVerticesHandle); + std::vector const & simVertices = *simVerticesHandle; + + edm::Handle > caloParticleHandle; + event.getByToken(label_cp_effic, caloParticleHandle); + std::vector const & caloParticles = *caloParticleHandle; + + tools_->getEventSetup(setup); + histoProducerAlgo_->setRecHitTools(tools_); + + edm::Handle recHitHandleEE; + event.getByToken(recHitsEE_, recHitHandleEE); + edm::Handle recHitHandleFH; + event.getByToken(recHitsFH_, recHitHandleFH); + edm::Handle recHitHandleBH; + event.getByToken(recHitsBH_, recHitHandleBH); + + std::map hitMap; + fillHitMap(hitMap, *recHitHandleEE,*recHitHandleFH,*recHitHandleBH); + + //Some general info on layers etc. + if (SaveGeneralInfo_){ + histoProducerAlgo_->fill_info_histos(histograms.histoProducerAlgo,totallayers_to_monitor_); + } + + // ############################################## + // fill caloparticles histograms + // ############################################## + LogTrace("HGCalValidator") << "\n# of CaloParticles: " << caloParticles.size() << "\n"; + std::vector selected_cPeff; + cpParametersAndSelection(histograms, caloParticles, simVertices, selected_cPeff); + + int w=0; //counter counting the number of sets of histograms + for (unsigned int www=0;www clusterHandle; + event.getByToken(labelToken[www],clusterHandle); + const reco::CaloClusterCollection &clusters = *clusterHandle; + + //Density + edm::Handle densityHandle; + event.getByToken( density_, densityHandle); + const Density &densities = *densityHandle; + + // ############################################## + // fill cluster histograms (LOOP OVER CLUSTERS) + // ############################################## + if(!dolayerclustersPlots_){continue;} + + histoProducerAlgo_->fill_generic_cluster_histos(histograms.histoProducerAlgo, + w,clusters,densities,caloParticles, + hitMap, + cummatbudg,totallayers_to_monitor_, + thicknesses_to_monitor_); + + for (unsigned int layerclusterIndex = 0; layerclusterIndex < clusters.size(); layerclusterIndex++) { + histoProducerAlgo_->fill_cluster_histos(histograms.histoProducerAlgo,w,clusters[layerclusterIndex]); + } + + LogTrace("HGCalValidator") << "\n# of layer clusters with " + << label[www].process()<<":" + << label[www].label()<<":" + << label[www].instance() + << ": " << clusters.size() << "\n"; + + } // End of for (unsigned int www=0;www & hitMap, + const HGCRecHitCollection & rechitsEE, + const HGCRecHitCollection & rechitsFH, + const HGCRecHitCollection & rechitsBH) const { + hitMap.clear(); + for (const auto& hit : rechitsEE) { + hitMap.emplace(hit.detid(), &hit); + } + + for (const auto& hit : rechitsFH) { + hitMap.emplace(hit.detid(), &hit); + } + + for (const auto& hit : rechitsBH) { + hitMap.emplace(hit.detid(), &hit); + } +} + diff --git a/Validation/HGCalValidation/plugins/SealModule.cc b/Validation/HGCalValidation/plugins/SealModule.cc new file mode 100644 index 0000000000000..ec323a99883d9 --- /dev/null +++ b/Validation/HGCalValidation/plugins/SealModule.cc @@ -0,0 +1,6 @@ +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "Validation/HGCalValidation/interface/HGCalValidator.h" + +DEFINE_FWK_MODULE(HGCalValidator); diff --git a/Validation/HGCalValidation/python/CaloParticleSelectionForEfficiency_cfi.py b/Validation/HGCalValidation/python/CaloParticleSelectionForEfficiency_cfi.py new file mode 100644 index 0000000000000..d0aafc9fca4c4 --- /dev/null +++ b/Validation/HGCalValidation/python/CaloParticleSelectionForEfficiency_cfi.py @@ -0,0 +1,23 @@ +import FWCore.ParameterSet.Config as cms + +CaloParticleSelectionForEfficiency = cms.PSet( + ptMinCP = cms.double(0.005), + ptMaxCP = cms.double(250.), + minRapidityCP = cms.double(-4.5), + maxRapidityCP = cms.double(4.5), + #--z position of the origin vertex less than lipCP + lipCP = cms.double(30.0), + #-- transverse component squared sum less that tipCP*tipCP + tipCP = cms.double(60), + chargedOnlyCP = cms.bool(False), + stableOnlyCP = cms.bool(False), + pdgIdCP = cms.vint32(11, -11, 13, -13, 22, 111, 211, -211, 321, -321), + #--signal only means no PU particles + signalOnlyCP = cms.bool(True), + #--intime only means no OOT PU particles + intimeOnlyCP = cms.bool(True), + #The total number of rechits + minHitCP = cms.int32(0) +) + + diff --git a/Validation/HGCalValidation/python/CaloParticleSelectionsForEfficiency_cff.py b/Validation/HGCalValidation/python/CaloParticleSelectionsForEfficiency_cff.py new file mode 100644 index 0000000000000..9e0a575873d5d --- /dev/null +++ b/Validation/HGCalValidation/python/CaloParticleSelectionsForEfficiency_cff.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +generalCpSelectorBlock = cms.PSet( + ptMinCP = cms.double(0.005), + ptMaxCP = cms.double(1e100), + minRapidityCP = cms.double(-4.5), + maxRapidityCP = cms.double(4.5), + chargedOnlyCP = cms.bool(True), + stableOnlyCP = cms.bool(False), + pdgIdCP = cms.vint32(11, -11, 13, -13, 22, 111, 211, -211, 321, -321), + #--signal only means no PU particles + signalOnlyCP = cms.bool(True), + #--intime only means no OOT PU particles + intimeOnlyCP = cms.bool(True), + #The total number of rechits + minHitCP = cms.int32(0) +) + +CpSelectorForEfficiencyVsEtaBlock = generalCpSelectorBlock.clone() +CpSelectorForEfficiencyVsPhiBlock = generalCpSelectorBlock.clone() +CpSelectorForEfficiencyVsPtBlock = generalCpSelectorBlock.clone(ptMin = 0.050 ) + diff --git a/Validation/HGCalValidation/python/HGCalPostProcessor_cff.py b/Validation/HGCalValidation/python/HGCalPostProcessor_cff.py index 048138fe92533..17316de56ad16 100644 --- a/Validation/HGCalValidation/python/HGCalPostProcessor_cff.py +++ b/Validation/HGCalValidation/python/HGCalPostProcessor_cff.py @@ -3,5 +3,16 @@ from Validation.HGCalValidation.HGCalSimHitsClient_cff import * from Validation.HGCalValidation.HGCalDigiClient_cff import * from Validation.HGCalValidation.HGCalRecHitsClient_cff import * +from Validation.HGCalValidation.PostProcessorHGCAL_cfi import postProcessorHGCAL -hgcalPostProcessor = cms.Sequence(hgcalSimHitClientEE+hgcalSimHitClientHEF+hgcalSimHitClientHEB+hgcalDigiClientEE+hgcalDigiClientHEF+hgcalDigiClientHEB+hgcalRecHitClientEE+hgcalRecHitClientHEF+hgcalRecHitClientHEB) +hgcalPostProcessor = cms.Sequence(hgcalSimHitClientEE + + hgcalSimHitClientHEF + + hgcalSimHitClientHEB + + hgcalDigiClientEE + + hgcalDigiClientHEF + + hgcalDigiClientHEB + + hgcalRecHitClientEE + + hgcalRecHitClientHEF + + hgcalRecHitClientHEB) + +hgcalValidatorPostProcessor = cms.Sequence(postProcessorHGCAL) diff --git a/Validation/HGCalValidation/python/HGCalValidator_cff.py b/Validation/HGCalValidation/python/HGCalValidator_cff.py new file mode 100644 index 0000000000000..4863ad2771dc4 --- /dev/null +++ b/Validation/HGCalValidation/python/HGCalValidator_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +from DQMServices.Core.DQM_cfg import * +DQMStore.collateHistograms = cms.untracked.bool(True) +from Validation.HGCalValidation.HGCalValidator_cfi import * + diff --git a/Validation/HGCalValidation/python/HGCalValidator_cfi.py b/Validation/HGCalValidation/python/HGCalValidator_cfi.py new file mode 100644 index 0000000000000..b373d1a138c2f --- /dev/null +++ b/Validation/HGCalValidation/python/HGCalValidator_cfi.py @@ -0,0 +1,53 @@ +import FWCore.ParameterSet.Config as cms + +from Validation.HGCalValidation.CaloParticleSelectionForEfficiency_cfi import * +from Validation.HGCalValidation.HGVHistoProducerAlgoBlock_cfi import * + +hgcalValidator = cms.EDAnalyzer( + "HGCalValidator", + + ### general settings ### + # selection of CP for evaluation of efficiency # + CaloParticleSelectionForEfficiency, + + ### reco input configuration ### + #2dlayerclusters, pfclusters, multiclusters + #label = cms.VInputTag(cms.InputTag("hgcalLayerClusters"), cms.InputTag("particleFlowClusterHGCal"), cms.InputTag("hgcalMultiClusters") ), + label = cms.VInputTag(cms.InputTag("hgcalLayerClusters")), + + #General info on layers etc. + SaveGeneralInfo = cms.untracked.bool(True), + #CaloParticle related plots + doCaloParticlePlots = cms.untracked.bool(True), + dolayerclustersPlots = cms.untracked.bool(True), + + #The cumulative material budget in front of each layer. To be more specific, it + #is the material budget just in front of the active material (not including it). + #This file is created using the official material budget code. + cummatbudinxo = cms.FileInPath('Validation/HGCalValidation/data/D28.cumulative.xo'), + + ### sim input configuration ### + label_cp_effic = cms.InputTag("mix","MergedCaloTruth"), + label_cp_fake = cms.InputTag("mix","MergedCaloTruth"), + + simVertices = cms.InputTag("g4SimHits"), + + #Total number of layers of HGCal that we want to monitor + #Could get this also from HGCalImagingAlgo::maxlayer but better to get it from here + totallayers_to_monitor = cms.int32(52), + #Thicknesses we want to monitor. -1 is for scintillator + thicknesses_to_monitor = cms.vint32(120,200,300,-1), + + # HistoProducerAlgo. Defines the set of plots to be booked and filled + histoProducerAlgoBlock = HGVHistoProducerAlgoBlock, + + ### output configuration + dirName = cms.string('HGCAL/HGCalValidator/') + +) + +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +premix_stage2.toModify(hgcalValidator, + label_cp_effic = "mixData:MergedCaloTruth", + label_cp_fake = "mixData:MergedCaloTruth" +) diff --git a/Validation/HGCalValidation/python/HGVHistoProducerAlgoBlock_cfi.py b/Validation/HGCalValidation/python/HGVHistoProducerAlgoBlock_cfi.py new file mode 100644 index 0000000000000..2a4aae9316568 --- /dev/null +++ b/Validation/HGCalValidation/python/HGVHistoProducerAlgoBlock_cfi.py @@ -0,0 +1,117 @@ +import FWCore.ParameterSet.Config as cms + +HGVHistoProducerAlgoBlock = cms.PSet( + + minEta = cms.double(-4.5), + maxEta = cms.double(4.5), + nintEta = cms.int32(100), + useFabsEta = cms.bool(False), + + #parameters for energy + minEne = cms.double(0.), + maxEne = cms.double(500.), + nintEne = cms.int32(250), + + #parameters for pt + minPt = cms.double(0.), + maxPt = cms.double(100.), + nintPt = cms.int32(100), + + #parameters for phi + minPhi = cms.double(-4.), + maxPhi = cms.double(4.), + nintPhi = cms.int32(100), + + #parameters for counting mixed hits clusters + minMixedHitsCluster = cms.double(0.), + maxMixedHitsCluster = cms.double(800.), + nintMixedHitsCluster = cms.int32(100), + + #parameters for the total amount of energy clustered by all layer clusters (fraction over caloparticles) + minEneCl = cms.double(0.), + maxEneCl = cms.double(110.), + nintEneCl = cms.int32(110), + + #parameters for the longitudinal depth barycenter + minLongDepBary = cms.double(0.), + maxLongDepBary = cms.double(110.), + nintLongDepBary = cms.int32(110), + + #z position of vertex + minZpos = cms.double(-550.), + maxZpos = cms.double(550.), + nintZpos = cms.int32(1100), + + #Parameters for the total number of layer clusters per layer + minTotNClsperlay = cms.double(0.), + maxTotNClsperlay = cms.double(50.), + nintTotNClsperlay = cms.int32(50), + + #Parameters for the energy clustered by layer clusters per layer (fraction) + minEneClperlay = cms.double(0.), + maxEneClperlay = cms.double(110.), + nintEneClperlay = cms.int32(110), + + #Parameters for the score both for: + #1. calo particle to layer clusters association per layer + #2. layer cluster to calo particles association per layer + minScore = cms.double(-1.01), + maxScore = cms.double(1.01), + nintScore = cms.int32(200), + + #Parameters for shared energy fraction. That is: + #1. Fraction of each of the layer clusters energy related to a + # calo particle over that calo particle's energy. + #2. Fraction of each of the calo particles energy + # related to a layer cluster over that layer cluster's energy. + minSharedEneFrac = cms.double(0.), + maxSharedEneFrac = cms.double(1.), + nintSharedEneFrac = cms.int32(100), + + #Parameters for the total number of layer clusters per thickness + minTotNClsperthick = cms.double(0.), + maxTotNClsperthick = cms.double(800.), + nintTotNClsperthick = cms.int32(100), + + #Parameters for the total number of cells per per thickness per layer + minTotNcellsperthickperlayer = cms.double(0.), + maxTotNcellsperthickperlayer = cms.double(500.), + nintTotNcellsperthickperlayer = cms.int32(100), + + #Parameters for the distance of cluster cells to seed cell per thickness per layer + minDisToSeedperthickperlayer = cms.double(0.), + maxDisToSeedperthickperlayer = cms.double(300.), + nintDisToSeedperthickperlayer = cms.int32(100), + + #Parameters for the energy weighted distance of cluster cells to seed cell per thickness per layer + minDisToSeedperthickperlayerenewei = cms.double(0.), + maxDisToSeedperthickperlayerenewei = cms.double(10.), + nintDisToSeedperthickperlayerenewei = cms.int32(50), + + #Parameters for the distance of cluster cells to max cell per thickness per layer + minDisToMaxperthickperlayer = cms.double(0.), + maxDisToMaxperthickperlayer = cms.double(300.), + nintDisToMaxperthickperlayer = cms.int32(100), + + #Parameters for the energy weighted distance of cluster cells to max cell per thickness per layer + minDisToMaxperthickperlayerenewei = cms.double(0.), + maxDisToMaxperthickperlayerenewei = cms.double(50.), + nintDisToMaxperthickperlayerenewei = cms.int32(50), + + #Parameters for the distance of cluster cells to max cell per thickness per layer + minDisSeedToMaxperthickperlayer = cms.double(0.), + maxDisSeedToMaxperthickperlayer = cms.double(300.), + nintDisSeedToMaxperthickperlayer = cms.int32(100), + + #Parameters for the energy of a cluster per thickness per layer + minClEneperthickperlayer = cms.double(0.), + maxClEneperthickperlayer = cms.double(10.), + nintClEneperthickperlayer = cms.int32(100), + + #Parameters for the energy density of cluster cells per thickness + minCellsEneDensperthick = cms.double(0.), + maxCellsEneDensperthick = cms.double(100.), + nintCellsEneDensperthick = cms.int32(200) + +) + diff --git a/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py new file mode 100644 index 0000000000000..0da0b313a3703 --- /dev/null +++ b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py @@ -0,0 +1,24 @@ +import FWCore.ParameterSet.Config as cms +from DQMServices.Core.DQMEDHarvester import DQMEDHarvester + +maxlayerzm = 52 # last layer of BH -z +maxlayerzp = 104 # last layer of BH +z + +eff_layers = ["effic_eta_layer{:02d} 'LayerCluster Efficiency vs #eta Layer{:02d} in z-' Num_CaloParticle_Eta_perlayer{:02d} Denom_CaloParticle_Eta_perlayer{:02d}".format(i, i%maxlayerzm+1, i, i) if (i51 +#+z: 52->103 +layerscheme = { 'lastLayerEEzm': 0, 'lastLayerFHzm': 0, 'maxlayerzm': 0, 'lastLayerEEzp': 0, 'lastLayerFHzp': 0, 'maxlayerzp': 0 } + +#Let's take the relevant values of layerscheme from the dqm file. +theDQMfile = "DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root" +if not os.path.isfile(theDQMfile): + print("Error: file", theDQMfile, "not found, exit") + sys.exit(0) + +#Take general info from the first file is sufficient. +thefile = TFile( theDQMfile ) +GeneralInfoDirectory = 'DQMData/Run 1/HGCAL/Run summary/HGCalValidator/GeneralInfo' + +if not gDirectory.GetDirectory( GeneralInfoDirectory ): + print("Error: GeneralInfo directory not found in DQM file, exit") + sys.exit(0) + +keys = gDirectory.GetDirectory( GeneralInfoDirectory ).GetListOfKeys() +key = keys[0] +layvalue = 0 +while key: + obj = key.ReadObj() + for laykey in layerscheme.keys(): + if laykey in obj.GetName(): + layvalue = obj.GetName()[len("<"+laykey+">i="):-len("")] + layerscheme[laykey] = layvalue + #print(layvalue) + key = keys.After(key) + +thefile.Close() + +print(layerscheme) +#TODO: Anticipating the fine/coarse layer information in CMSSW we overwrite values from DQM file +#For now values returned for +# 'lastLayerFHzp': '104', 'lastLayerFHzm': '52' +#are not the one expected. Will come back to this when there will be info in CMSSW to put in DQM file. +layerscheme = { 'lastLayerEEzm': 28, 'lastLayerFHzm': 40, 'maxlayerzm': 52, 'lastLayerEEzp': 80, 'lastLayerFHzp': 92, 'maxlayerzp': 104 } +print(layerscheme) + +lastLayerEEzm = layerscheme['lastLayerEEzm'] # last layer of EE -z +lastLayerFHzm = layerscheme['lastLayerFHzm'] # last layer of FH -z +maxlayerzm = layerscheme['maxlayerzm'] # last layer of BH -z +lastLayerEEzp = layerscheme['lastLayerEEzp'] # last layer of EE +z +lastLayerFHzp = layerscheme['lastLayerFHzp'] # last layer of FH +z +maxlayerzp = layerscheme['maxlayerzp'] # last layer of BH +z + +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } +_legend_common = {"legendDx": -0.3, + "legendDy": -0.05, + "legendDw": 0.1} + +_SelectedCaloParticles = PlotGroup("SelectedCaloParticles", [ + Plot("num_caloparticle_eta", xtitle="", **_common), + Plot("caloparticle_energy", xtitle="", **_common), + Plot("caloparticle_pt", xtitle="", **_common), + Plot("caloparticle_phi", xtitle="", **_common), + Plot("Eta vs Zorigin", xtitle="", **_common), + ]) + +#Need to adjust the statbox to see better the plot +_common = {"stat": True, "drawStyle": "hist", "statx": 0.38, "staty": 0.68 } +_num_reco_cluster_eta = PlotGroup("num_reco_cluster_eta", [ + Plot("num_reco_cluster_eta", xtitle="", **_common), +],ncols=1) +#Back to normal +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } + +_mixedhitsclusters = PlotGroup("mixedhitsclusters", [ + Plot("mixedhitscluster_zminus", xtitle="", **_common), + Plot("mixedhitscluster_zplus", xtitle="", **_common), +],ncols=2) + +#Just to prevent the stabox covering the plot +_common = {"stat": True, "drawStyle": "hist", "statx": 0.45, "staty": 0.65 } + +_energyclustered = PlotGroup("energyclustered", [ + Plot("energyclustered_zminus", xtitle="", **_common), + Plot("energyclustered_zplus", xtitle="", **_common), +],ncols=2) + +#Coming back to the usual box definition +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } + +_longdepthbarycentre = PlotGroup("longdepthbarycentre", [ + Plot("longdepthbarycentre_zminus", xtitle="", **_common), + Plot("longdepthbarycentre_zplus", xtitle="", **_common), +],ncols=2) + +_common_layerperthickness = {} +_common_layerperthickness.update(_common) +_common_layerperthickness['xmin'] = 0. +_common_layerperthickness['xmax'] = 100 + +_totclusternum_thick = PlotGroup("totclusternum_thick", [ + Plot("totclusternum_thick_120", xtitle="", **_common_layerperthickness), + Plot("totclusternum_thick_200", xtitle="", **_common_layerperthickness), + Plot("totclusternum_thick_300", xtitle="", **_common_layerperthickness), + Plot("totclusternum_thick_-1", xtitle="", **_common_layerperthickness), + Plot("mixedhitscluster", xtitle="", **_common_layerperthickness), +]) + +#We will plot the density in logy scale. +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65} + +_cellsenedens_thick = PlotGroup("cellsenedens_thick", [ + Plot("cellsenedens_thick_120", xtitle="", **_common), + Plot("cellsenedens_thick_200", xtitle="", **_common), + Plot("cellsenedens_thick_300", xtitle="", **_common), + Plot("cellsenedens_thick_-1", xtitle="", **_common), +]) + +#Coming back to the usual box definition +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } + + +#-------------------------------------------------------------------------------------------- +# z- +#-------------------------------------------------------------------------------------------- +_totclusternum_layer_EE_zminus = PlotGroup("totclusternum_layer_EE_zminus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_totclusternum_layer_FH_zminus = PlotGroup("totclusternum_layer_FH_zminus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_totclusternum_layer_BH_zminus = PlotGroup("totclusternum_layer_BH_zminus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +_energyclustered_perlayer_EE_zminus = PlotGroup("energyclustered_perlayer_EE_zminus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_energyclustered_perlayer_FH_zminus = PlotGroup("energyclustered_perlayer_FH_zminus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_energyclustered_perlayer_BH_zminus = PlotGroup("energyclustered_perlayer_BH_zminus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_common_cells = {} +_common_cells.update(_common) +_common_cells["xmin"] = 0 +_common_cells["xmax"] = 50 +_common_cells["ymin"] = 0.1 +_common_cells["ymax"] = 10000 +_common_cells["ylog"] = True +_cellsnum_perthick_perlayer_120_EE_zminus = PlotGroup("cellsnum_perthick_perlayer_120_EE_zminus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm) +], ncols=4) + +_cellsnum_perthick_perlayer_120_FH_zminus = PlotGroup("cellsnum_perthick_perlayer_120_FH_zminus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_cellsnum_perthick_perlayer_120_BH_zminus = PlotGroup("cellsnum_perthick_perlayer_120_BH_zminus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_cellsnum_perthick_perlayer_200_EE_zminus = PlotGroup("cellsnum_perthick_perlayer_200_EE_zminus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm) +], ncols=4) + +_cellsnum_perthick_perlayer_200_FH_zminus = PlotGroup("cellsnum_perthick_perlayer_200_FH_zminus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_cellsnum_perthick_perlayer_200_BH_zminus = PlotGroup("cellsnum_perthick_perlayer_200_BH_zminus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_cellsnum_perthick_perlayer_300_EE_zminus = PlotGroup("cellsnum_perthick_perlayer_300_EE_zminus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm) +], ncols=4) + +_cellsnum_perthick_perlayer_300_FH_zminus = PlotGroup("cellsnum_perthick_perlayer_300_FH_zminus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_cellsnum_perthick_perlayer_300_BH_zminus = PlotGroup("cellsnum_perthick_perlayer_300_BH_zminus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_cellsnum_perthick_perlayer_scint_EE_zminus = PlotGroup("cellsnum_perthick_perlayer_-1_EE_zminus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm) +], ncols=4) + +_cellsnum_perthick_perlayer_scint_FH_zminus = PlotGroup("cellsnum_perthick_perlayer_-1_FH_zminus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_cellsnum_perthick_perlayer_scint_BH_zminus = PlotGroup("cellsnum_perthick_perlayer_-1_BH_zminus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_common_distance = {} +_common_distance.update(_common) +_common_distance.update(_legend_common) +_common_distance["xmax"] = 150 +_common_distance["stat"] = False +_common_distance["ymin"] = 1e-3 +_common_distance["ymax"] = 10000 +_common_distance["ylog"] = True + +_distancetomaxcell_perthickperlayer_120_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_120_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_120_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_120_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_120_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_120_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancetomaxcell_perthickperlayer_200_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_200_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_200_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_200_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_200_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_200_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancetomaxcell_perthickperlayer_300_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_300_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_300_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_300_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_300_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_300_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_distancetomaxcell_perthickperlayer_scint_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_-1_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_scint_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_-1_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_scint_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_-1_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancebetseedandmaxcell_perthickperlayer_120_EE_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_EE_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_120_FH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_FH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_120_BH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_BH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancebetseedandmaxcell_perthickperlayer_200_EE_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_EE_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_200_FH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_FH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_200_BH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_BH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancebetseedandmaxcell_perthickperlayer_300_EE_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_EE_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_300_FH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_FH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_300_BH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_BH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_distancebetseedandmaxcell_perthickperlayer_scint_EE_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_EE_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_scint_FH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_FH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_scint_BH_zminus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_BH_zminus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_EE_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_EE_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_FH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_FH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_BH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_BH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_EE_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_EE_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_FH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_FH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_BH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_BH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_EE_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_EE_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_FH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_FH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_BH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_BH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_EE_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_EE_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_FH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_FH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_BH_zminus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_BH_zminus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancetoseedcell_perthickperlayer_120_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_120_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_120_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_120_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_120_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_120_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancetoseedcell_perthickperlayer_200_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_200_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_200_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_200_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_200_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_200_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancetoseedcell_perthickperlayer_300_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_300_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_300_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_300_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_300_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_300_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_distancetoseedcell_perthickperlayer_scint_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_-1_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_scint_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_-1_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_scint_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_-1_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#===================================================================================================================== +#---------------------------------------------------------------------------------------------------------------- +#We need points for the weighted plots +_common = {"stat": True, "drawStyle": "EP", "staty": 0.65 } +#120 um +_distancetomaxcell_perthickperlayer_eneweighted_120_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_120_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_120_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancetomaxcell_perthickperlayer_eneweighted_200_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_200_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_200_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancetomaxcell_perthickperlayer_eneweighted_300_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_300_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_300_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) +#scint um +_distancetomaxcell_perthickperlayer_eneweighted_scint_EE_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_EE_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_scint_FH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_FH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_scint_BH_zminus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_BH_zminus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancetoseedcell_perthickperlayer_eneweighted_120_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_120_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_120_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#200 um +_distancetoseedcell_perthickperlayer_eneweighted_200_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_200_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_200_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#300 um +_distancetoseedcell_perthickperlayer_eneweighted_300_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_300_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_300_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#scint um +_distancetoseedcell_perthickperlayer_eneweighted_scint_EE_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_EE_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_scint_FH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_FH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzm,lastLayerFHzm) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_scint_BH_zminus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_BH_zminus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzm,maxlayerzm) +], ncols=4) + +#Coming back to the usual definition +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } + +#-------------------------------------------------------------------------------------------- +# z+ +#-------------------------------------------------------------------------------------------- +_totclusternum_layer_EE_zplus = PlotGroup("totclusternum_layer_EE_zplus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_totclusternum_layer_FH_zplus = PlotGroup("totclusternum_layer_FH_zplus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_totclusternum_layer_BH_zplus = PlotGroup("totclusternum_layer_BH_zplus", [ + Plot("totclusternum_layer_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +_energyclustered_perlayer_EE_zplus = PlotGroup("energyclustered_perlayer_EE_zplus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_energyclustered_perlayer_FH_zplus = PlotGroup("energyclustered_perlayer_FH_zplus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_energyclustered_perlayer_BH_zplus = PlotGroup("energyclustered_perlayer_BH_zplus", [ + Plot("energyclustered_perlayer{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_cellsnum_perthick_perlayer_120_EE_zplus = PlotGroup("cellsnum_perthick_perlayer_120_EE_zplus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_cellsnum_perthick_perlayer_120_FH_zplus = PlotGroup("cellsnum_perthick_perlayer_120_FH_zplus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) +_cellsnum_perthick_perlayer_120_BH_zplus = PlotGroup("cellsnum_perthick_perlayer_120_BH_zplus", [ + Plot("cellsnum_perthick_perlayer_120_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_cellsnum_perthick_perlayer_200_EE_zplus = PlotGroup("cellsnum_perthick_perlayer_200_EE_zplus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_cellsnum_perthick_perlayer_200_FH_zplus = PlotGroup("cellsnum_perthick_perlayer_200_FH_zplus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_cellsnum_perthick_perlayer_200_BH_zplus = PlotGroup("cellsnum_perthick_perlayer_200_BH_zplus", [ + Plot("cellsnum_perthick_perlayer_200_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) +#300 um +_cellsnum_perthick_perlayer_300_EE_zplus = PlotGroup("cellsnum_perthick_perlayer_300_EE_zplus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_cellsnum_perthick_perlayer_300_FH_zplus = PlotGroup("cellsnum_perthick_perlayer_300_FH_zplus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) +_cellsnum_perthick_perlayer_300_BH_zplus = PlotGroup("cellsnum_perthick_perlayer_300_BH_zplus", [ + Plot("cellsnum_perthick_perlayer_300_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_cellsnum_perthick_perlayer_scint_EE_zplus = PlotGroup("cellsnum_perthick_perlayer_-1_EE_zplus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_cellsnum_perthick_perlayer_scint_FH_zplus = PlotGroup("cellsnum_perthick_perlayer_-1_FH_zplus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_cellsnum_perthick_perlayer_scint_BH_zplus = PlotGroup("cellsnum_perthick_perlayer_-1_BH_zplus", [ + Plot("cellsnum_perthick_perlayer_-1_{:02d}".format(i), xtitle="", **_common_cells) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_common_distance = {} +_common_distance.update(_common) +_common_distance.update(_legend_common) +_common_distance["xmax"] = 150 +_common_distance["stat"] = False +_common_distance["ymin"] = 1e-3 +_common_distance["ymax"] = 10000 +_common_distance["ylog"] = True + +_distancetomaxcell_perthickperlayer_120_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_120_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_120_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_120_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_120_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_120_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancetomaxcell_perthickperlayer_200_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_200_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_200_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_200_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_200_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_200_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancetomaxcell_perthickperlayer_300_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_300_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_300_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_300_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_300_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_300_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancetomaxcell_perthickperlayer_scint_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_-1_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_scint_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_-1_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_scint_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_-1_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancebetseedandmaxcell_perthickperlayer_120_EE_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_EE_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_120_FH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_FH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_120_BH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_120_BH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancebetseedandmaxcell_perthickperlayer_200_EE_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_EE_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_200_FH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_FH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_200_BH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_200_BH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancebetseedandmaxcell_perthickperlayer_300_EE_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_EE_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_300_FH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_FH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_300_BH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_300_BH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancebetseedandmaxcell_perthickperlayer_scint_EE_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_EE_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_scint_FH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_FH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcell_perthickperlayer_scint_BH_zplus = PlotGroup("distancebetseedandmaxcell_perthickperlayer_-1_BH_zplus", [ + Plot("distancebetseedandmaxcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_EE_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_EE_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_FH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_FH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_BH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_BH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_EE_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_EE_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_FH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_FH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_BH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_BH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_EE_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_EE_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_FH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_FH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_BH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_BH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_EE_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_EE_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_FH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_FH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_BH_zplus = PlotGroup("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_BH_zplus", [ + Plot("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancetoseedcell_perthickperlayer_120_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_120_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_120_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_120_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_120_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_120_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancetoseedcell_perthickperlayer_200_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_200_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_200_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_200_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_200_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_200_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancetoseedcell_perthickperlayer_300_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_300_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_300_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_300_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_300_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_300_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancetoseedcell_perthickperlayer_scint_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_-1_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_scint_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_-1_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_scint_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_-1_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#===================================================================================================================== +#---------------------------------------------------------------------------------------------------------------- +#We need points for the weighted plots +_common = {"stat": True, "drawStyle": "EP", "staty": 0.65 } + +#120 um +_distancetomaxcell_perthickperlayer_eneweighted_120_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_120_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_120_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_120_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancetomaxcell_perthickperlayer_eneweighted_200_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) +_distancetomaxcell_perthickperlayer_eneweighted_200_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_200_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_200_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancetomaxcell_perthickperlayer_eneweighted_300_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_300_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_300_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_300_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancetomaxcell_perthickperlayer_eneweighted_scint_EE_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_EE_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_scint_FH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_FH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetomaxcell_perthickperlayer_eneweighted_scint_BH_zplus = PlotGroup("distancetomaxcell_perthickperlayer_eneweighted_-1_BH_zplus", [ + Plot("distancetomaxcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#---------------------------------------------------------------------------------------------------------------- +#120 um +_distancetoseedcell_perthickperlayer_eneweighted_120_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_120_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_120_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_120_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_120_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#200 um +_distancetoseedcell_perthickperlayer_eneweighted_200_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_200_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_200_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_200_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_200_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#300 um +_distancetoseedcell_perthickperlayer_eneweighted_300_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_300_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_300_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_300_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_300_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) + +#scint um +_distancetoseedcell_perthickperlayer_eneweighted_scint_EE_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_EE_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(maxlayerzm,lastLayerEEzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_scint_FH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_FH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerEEzp,lastLayerFHzp) +], ncols=4) + +_distancetoseedcell_perthickperlayer_eneweighted_scint_BH_zplus = PlotGroup("distancetoseedcell_perthickperlayer_eneweighted_-1_BH_zplus", [ + Plot("distancetoseedcell_perthickperlayer_eneweighted_-1_{:02d}".format(i), xtitle="", **_common) for i in range(lastLayerFHzp,maxlayerzp) +], ncols=4) +#Just in case we add some plots below to be on the safe side. +_common = {"stat": True, "drawStyle": "hist", "staty": 0.65 } + +#-------------------------------------------------------------------------------------------- +# z- +#-------------------------------------------------------------------------------------------- + +_common_score = {"title": "Score CaloParticle to LayerClusters in z-", + "stat": False, + "ymin": 0.1, + "ymax": 1000, + "xmin": 0, + "xmax": 1, + "drawStyle": "hist", + "lineWidth": 1, + "ylog": True + } +_common_score.update(_legend_common) +_score_caloparticle_to_layerclusters_zminus = PlotGroup("score_caloparticle_to_layercluster_zminus", [ + Plot("Score_caloparticle2layercl_perlayer{:02d}".format(i), xtitle="Layer {:02d} in z-".format(i%maxlayerzm+1) if (i +#include + +#include "Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" +#include "TMath.h" +#include "TLatex.h" +#include "TF1.h" + +using namespace std; + +//Parameters for the score cut. Later, this will become part of the +//configuration parameter for the HGCAL associator. +const double ScoreCutLCtoCP_ = 0.2; +const double ScoreCutCPtoLC_ = 0.2; + +HGVHistoProducerAlgo::HGVHistoProducerAlgo(const edm::ParameterSet& pset) : + //parameters for eta + minEta_(pset.getParameter("minEta")), + maxEta_(pset.getParameter("maxEta")), + nintEta_(pset.getParameter("nintEta")), + useFabsEta_(pset.getParameter("useFabsEta")), + + //parameters for energy + minEne_(pset.getParameter("minEne")), + maxEne_(pset.getParameter("maxEne")), + nintEne_(pset.getParameter("nintEne")), + + //parameters for pt + minPt_(pset.getParameter("minPt")), + maxPt_(pset.getParameter("maxPt")), + nintPt_(pset.getParameter("nintPt")), + + //parameters for phi + minPhi_(pset.getParameter("minPhi")), + maxPhi_(pset.getParameter("maxPhi")), + nintPhi_(pset.getParameter("nintPhi")), + + //parameters for counting mixed hits clusters + minMixedHitsCluster_(pset.getParameter("minMixedHitsCluster")), + maxMixedHitsCluster_(pset.getParameter("maxMixedHitsCluster")), + nintMixedHitsCluster_(pset.getParameter("nintMixedHitsCluster")), + + //parameters for the total amount of energy clustered by all layer clusters (fraction over caloparticles) + minEneCl_(pset.getParameter("minEneCl")), + maxEneCl_(pset.getParameter("maxEneCl")), + nintEneCl_(pset.getParameter("nintEneCl")), + + //parameters for the longitudinal depth barycenter. + minLongDepBary_(pset.getParameter("minLongDepBary")), + maxLongDepBary_(pset.getParameter("maxLongDepBary")), + nintLongDepBary_(pset.getParameter("nintLongDepBary")), + + //parameters for z positionof vertex plots + minZpos_(pset.getParameter("minZpos")), + maxZpos_(pset.getParameter("maxZpos")), + nintZpos_(pset.getParameter("nintZpos")), + + //Parameters for the total number of layer clusters per layer + minTotNClsperlay_(pset.getParameter("minTotNClsperlay")), + maxTotNClsperlay_(pset.getParameter("maxTotNClsperlay")), + nintTotNClsperlay_(pset.getParameter("nintTotNClsperlay")), + + //Parameters for the energy clustered by layer clusters per layer (fraction over caloparticles) + minEneClperlay_(pset.getParameter("minEneClperlay")), + maxEneClperlay_(pset.getParameter("maxEneClperlay")), + nintEneClperlay_(pset.getParameter("nintEneClperlay")), + + //Parameters for the score both for: + //1. calo particle to layer clusters association per layer + //2. layer cluster to calo particles association per layer + minScore_(pset.getParameter("minScore")), + maxScore_(pset.getParameter("maxScore")), + nintScore_(pset.getParameter("nintScore")), + + //Parameters for shared energy fraction. That is: + //1. Fraction of each of the layer clusters energy related to a + //calo particle over that calo particle's energy. + //2. Fraction of each of the calo particles energy + //related to a layer cluster over that layer cluster's energy. + minSharedEneFrac_(pset.getParameter("minSharedEneFrac")), + maxSharedEneFrac_(pset.getParameter("maxSharedEneFrac")), + nintSharedEneFrac_(pset.getParameter("nintSharedEneFrac")), + + //Parameters for the total number of layer clusters per thickness + minTotNClsperthick_(pset.getParameter("minTotNClsperthick")), + maxTotNClsperthick_(pset.getParameter("maxTotNClsperthick")), + nintTotNClsperthick_(pset.getParameter("nintTotNClsperthick")), + + //Parameters for the total number of cells per per thickness per layer + minTotNcellsperthickperlayer_(pset.getParameter("minTotNcellsperthickperlayer")), + maxTotNcellsperthickperlayer_(pset.getParameter("maxTotNcellsperthickperlayer")), + nintTotNcellsperthickperlayer_(pset.getParameter("nintTotNcellsperthickperlayer")), + + //Parameters for the distance of cluster cells to seed cell per thickness per layer + minDisToSeedperthickperlayer_(pset.getParameter("minDisToSeedperthickperlayer")), + maxDisToSeedperthickperlayer_(pset.getParameter("maxDisToSeedperthickperlayer")), + nintDisToSeedperthickperlayer_(pset.getParameter("nintDisToSeedperthickperlayer")), + + //Parameters for the energy weighted distance of cluster cells to seed cell per thickness per layer + minDisToSeedperthickperlayerenewei_(pset.getParameter("minDisToSeedperthickperlayerenewei")), + maxDisToSeedperthickperlayerenewei_(pset.getParameter("maxDisToSeedperthickperlayerenewei")), + nintDisToSeedperthickperlayerenewei_(pset.getParameter("nintDisToSeedperthickperlayerenewei")), + + //Parameters for the distance of cluster cells to max cell per thickness per layer + minDisToMaxperthickperlayer_(pset.getParameter("minDisToMaxperthickperlayer")), + maxDisToMaxperthickperlayer_(pset.getParameter("maxDisToMaxperthickperlayer")), + nintDisToMaxperthickperlayer_(pset.getParameter("nintDisToMaxperthickperlayer")), + + //Parameters for the energy weighted distance of cluster cells to max cell per thickness per layer + minDisToMaxperthickperlayerenewei_(pset.getParameter("minDisToMaxperthickperlayerenewei")), + maxDisToMaxperthickperlayerenewei_(pset.getParameter("maxDisToMaxperthickperlayerenewei")), + nintDisToMaxperthickperlayerenewei_(pset.getParameter("nintDisToMaxperthickperlayerenewei")), + + //Parameters for the distance of seed cell to max cell per thickness per layer + minDisSeedToMaxperthickperlayer_(pset.getParameter("minDisSeedToMaxperthickperlayer")), + maxDisSeedToMaxperthickperlayer_(pset.getParameter("maxDisSeedToMaxperthickperlayer")), + nintDisSeedToMaxperthickperlayer_(pset.getParameter("nintDisSeedToMaxperthickperlayer")), + + //Parameters for the energy of a cluster per thickness per layer + minClEneperthickperlayer_(pset.getParameter("minClEneperthickperlayer")), + maxClEneperthickperlayer_(pset.getParameter("maxClEneperthickperlayer")), + nintClEneperthickperlayer_(pset.getParameter("nintClEneperthickperlayer")), + + //Parameters for the energy density of cluster cells per thickness + minCellsEneDensperthick_(pset.getParameter("minCellsEneDensperthick")), + maxCellsEneDensperthick_(pset.getParameter("maxCellsEneDensperthick")), + nintCellsEneDensperthick_(pset.getParameter("nintCellsEneDensperthick")) + +{} + +HGVHistoProducerAlgo::~HGVHistoProducerAlgo() {} + +void HGVHistoProducerAlgo::bookInfo(DQMStore::ConcurrentBooker& ibook, Histograms& histograms) { + + histograms.lastLayerEEzm = ibook.bookInt("lastLayerEEzm"); + histograms.lastLayerFHzm = ibook.bookInt("lastLayerFHzm"); + histograms.maxlayerzm = ibook.bookInt("maxlayerzm"); + histograms.lastLayerEEzp = ibook.bookInt("lastLayerEEzp"); + histograms.lastLayerFHzp = ibook.bookInt("lastLayerFHzp"); + histograms.maxlayerzp = ibook.bookInt("maxlayerzp"); + +} + +void HGVHistoProducerAlgo::bookCaloParticleHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms,int pdgid) { + + histograms.h_caloparticle_eta[pdgid] = ibook.book1D("num_caloparticle_eta","N of caloparticle vs eta",nintEta_,minEta_,maxEta_); + histograms.h_caloparticle_eta_Zorigin[pdgid] = ibook.book2D("Eta vs Zorigin", "Eta vs Zorigin", nintEta_, minEta_, maxEta_, nintZpos_, minZpos_, maxZpos_); + + histograms.h_caloparticle_energy[pdgid] = ibook.book1D("caloparticle_energy", "Energy of caloparticle", nintEne_,minEne_,maxEne_); + histograms.h_caloparticle_pt[pdgid] = ibook.book1D("caloparticle_pt", "Pt of caloparticle", nintPt_,minPt_,maxPt_); + histograms.h_caloparticle_phi[pdgid] = ibook.book1D("caloparticle_phi", "Phi of caloparticle", nintPhi_,minPhi_,maxPhi_); + + +} + + +void HGVHistoProducerAlgo::bookClusterHistos(DQMStore::ConcurrentBooker& ibook, Histograms& histograms, unsigned layers, std::vector thicknesses, std::string pathtomatbudfile) { + + //--------------------------------------------------------------------------------------------------------------------------- + histograms.h_cluster_eta.push_back( ibook.book1D("num_reco_cluster_eta","N of reco clusters vs eta",nintEta_,minEta_,maxEta_) ); + + //--------------------------------------------------------------------------------------------------------------------------- + //z- + histograms.h_mixedhitscluster_zminus.push_back( ibook.book1D("mixedhitscluster_zminus","N of reco clusters that contain hits of more than one kind in z-",nintMixedHitsCluster_,minMixedHitsCluster_,maxMixedHitsCluster_) ); + //z+ + histograms.h_mixedhitscluster_zplus.push_back( ibook.book1D("mixedhitscluster_zplus","N of reco clusters that contain hits of more than one kind in z+",nintMixedHitsCluster_,minMixedHitsCluster_,maxMixedHitsCluster_) ); + + //--------------------------------------------------------------------------------------------------------------------------- + //z- + histograms.h_energyclustered_zminus.push_back( ibook.book1D("energyclustered_zminus","percent of total energy clustered by all layer clusters over caloparticles energy in z-",nintEneCl_,minEneCl_,maxEneCl_) ); + //z+ + histograms.h_energyclustered_zplus.push_back( ibook.book1D("energyclustered_zplus","percent of total energy clustered by all layer clusters over caloparticles energy in z+",nintEneCl_,minEneCl_,maxEneCl_) ); + + //--------------------------------------------------------------------------------------------------------------------------- + //z- + std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find("Validation")); + histograms.h_longdepthbarycentre_zminus.push_back( ibook.book1D("longdepthbarycentre_zminus","The longitudinal depth barycentre in z- for "+subpathtomat,nintLongDepBary_,minLongDepBary_,maxLongDepBary_) ); + //z+ + histograms.h_longdepthbarycentre_zplus.push_back( ibook.book1D("longdepthbarycentre_zplus","The longitudinal depth barycentre in z+ for "+subpathtomat,nintLongDepBary_,minLongDepBary_,maxLongDepBary_) ); + + + //--------------------------------------------------------------------------------------------------------------------------- + for (unsigned ilayer = 0; ilayer < 2*layers; ++ilayer) { + auto istr1 = std::to_string(ilayer); + while(istr1.size() < 2) {istr1.insert(0, "0");} + //We will make a mapping to the regural layer naming plus z- or z+ for convenience + std::string istr2 = ""; + //First with the -z endcap + if (ilayer < layers){ + istr2 = std::to_string(ilayer + 1) + " in z-"; + }else { //Then for the +z + istr2 = std::to_string(ilayer - 51) + " in z+"; + } + histograms.h_clusternum_perlayer[ilayer] = ibook.book1D("totclusternum_layer_"+istr1,"total number of layer clusters for layer "+istr2,nintTotNClsperlay_,minTotNClsperlay_,maxTotNClsperlay_); + histograms.h_energyclustered_perlayer[ilayer] = ibook.book1D("energyclustered_perlayer"+istr1,"percent of total energy clustered by layer clusters over caloparticles energy for layer "+istr2,nintEneClperlay_,minEneClperlay_,maxEneClperlay_); + histograms.h_score_layercl2caloparticle_perlayer[ilayer] = ibook.book1D("Score_layercl2caloparticle_perlayer"+istr1, "Score of Layer Cluster per CaloParticle for layer "+istr2, nintScore_,minScore_,maxScore_); + histograms.h_score_caloparticle2layercl_perlayer[ilayer] = ibook.book1D("Score_caloparticle2layercl_perlayer"+istr1, "Score of CaloParticle per Layer Cluster for layer "+istr2, nintScore_,minScore_,maxScore_); + histograms.h_energy_vs_score_caloparticle2layercl_perlayer[ilayer] = ibook.book2D("Energy_vs_Score_caloparticle2layer_perlayer"+istr1, "Energy vs Score of CaloParticle per Layer Cluster for layer "+istr2, nintScore_,minScore_,maxScore_, nintSharedEneFrac_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_energy_vs_score_layercl2caloparticle_perlayer[ilayer] = ibook.book2D("Energy_vs_Score_layer2caloparticle_perlayer"+istr1, "Energy vs Score of Layer Cluster per CaloParticle Layer for layer "+istr2, nintScore_,minScore_,maxScore_, nintSharedEneFrac_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_caloparticle2layercl_perlayer[ilayer] = ibook.book1D("SharedEnergy_caloparticle2layercl_perlayer"+istr1, "Shared Energy of CaloParticle per Layer Cluster for layer "+istr2, nintSharedEneFrac_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer[ilayer] = ibook.bookProfile("SharedEnergy_caloparticle2layercl_vs_eta_perlayer"+istr1, "Shared Energy of CaloParticle vs #eta per best Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer[ilayer] = ibook.bookProfile("SharedEnergy_caloparticle2layercl_vs_phi_perlayer"+istr1, "Shared Energy of CaloParticle vs #phi per best Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_layercl2caloparticle_perlayer[ilayer] = ibook.book1D("SharedEnergy_layercluster2caloparticle_perlayer"+istr1, "Shared Energy of Layer Cluster per Layer Calo Particle for layer "+istr2, nintSharedEneFrac_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer[ilayer] = ibook.bookProfile("SharedEnergy_layercl2caloparticle_vs_eta_perlayer"+istr1, "Shared Energy of LayerCluster vs #eta per best Calo Particle for layer "+istr2, nintEta_, minEta_, maxEta_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer[ilayer] = ibook.bookProfile("SharedEnergy_layercl2caloparticle_vs_phi_perlayer"+istr1, "Shared Energy of LayerCluster vs #phi per best Calo Particle for layer "+istr2, nintPhi_, minPhi_, maxPhi_, minSharedEneFrac_, maxSharedEneFrac_); + histograms.h_num_caloparticle_eta_perlayer[ilayer] = ibook.book1D("Num_CaloParticle_Eta_perlayer"+istr1, "Num CaloParticle Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_numDup_caloparticle_eta_perlayer[ilayer] = ibook.book1D("NumDup_CaloParticle_Eta_perlayer"+istr1, "Num Duplicate CaloParticle Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_denom_caloparticle_eta_perlayer[ilayer] = ibook.book1D("Denom_CaloParticle_Eta_perlayer"+istr1, "Denom CaloParticle Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_num_caloparticle_phi_perlayer[ilayer] = ibook.book1D("Num_CaloParticle_Phi_perlayer"+istr1, "Num CaloParticle Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_numDup_caloparticle_phi_perlayer[ilayer] = ibook.book1D("NumDup_CaloParticle_Phi_perlayer"+istr1, "Num Duplicate CaloParticle Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_denom_caloparticle_phi_perlayer[ilayer] = ibook.book1D("Denom_CaloParticle_Phi_perlayer"+istr1, "Denom CaloParticle Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_num_layercl_eta_perlayer[ilayer] = ibook.book1D("Num_LayerCluster_Eta_perlayer"+istr1, "Num LayerCluster Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_numMerge_layercl_eta_perlayer[ilayer] = ibook.book1D("NumMerge_LayerCluster_Eta_perlayer"+istr1, "Num Merge LayerCluster Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_denom_layercl_eta_perlayer[ilayer] = ibook.book1D("Denom_LayerCluster_Eta_perlayer"+istr1, "Denom LayerCluster Eta per Layer Cluster for layer "+istr2, nintEta_, minEta_, maxEta_); + histograms.h_num_layercl_phi_perlayer[ilayer] = ibook.book1D("Num_LayerCluster_Phi_perlayer"+istr1, "Num LayerCluster Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_numMerge_layercl_phi_perlayer[ilayer] = ibook.book1D("NumMerge_LayerCluster_Phi_perlayer"+istr1, "Num Merge LayerCluster Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_denom_layercl_phi_perlayer[ilayer] = ibook.book1D("Denom_LayerCluster_Phi_perlayer"+istr1, "Denom LayerCluster Phi per Layer Cluster for layer "+istr2, nintPhi_, minPhi_, maxPhi_); + histograms.h_cellAssociation_perlayer[ilayer] = ibook.book1D("cellAssociation_perlayer"+istr1, "Cell Association for layer "+istr2, 5, -4., 1.); + histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(2, "TN(purity)"); + histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(3, "FN(ineff.)"); + histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(4, "FP(fake)"); + histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(5, "TP(eff.)"); + } + + //--------------------------------------------------------------------------------------------------------------------------- + for(std::vector::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) { + auto istr = std::to_string(*it); + histograms.h_clusternum_perthick[(*it)] = ibook.book1D("totclusternum_thick_"+istr,"total number of layer clusters for thickness "+istr,nintTotNClsperthick_,minTotNClsperthick_,maxTotNClsperthick_); + //--- + histograms.h_cellsenedens_perthick[(*it)] = ibook.book1D("cellsenedens_thick_"+istr,"energy density of cluster cells for thickness "+istr,nintCellsEneDensperthick_,minCellsEneDensperthick_,maxCellsEneDensperthick_); + } + + //--------------------------------------------------------------------------------------------------------------------------- + //Not all combination exists but we should keep them all for cross checking reason. + for(std::vector::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) { + for (unsigned ilayer = 0; ilayer < 2*layers; ++ilayer) { + auto istr1 = std::to_string(*it); + auto istr2 = std::to_string(ilayer); + while(istr2.size() < 2) + istr2.insert(0, "0"); + auto istr = istr1 + "_" + istr2; + //We will make a mapping to the regural layer naming plus z- or z+ for convenience + std::string istr3 = ""; + //First with the -z endcap + if (ilayer < layers){ + istr3 = std::to_string(ilayer + 1) + " in z- "; + }else { //Then for the +z + istr3 = std::to_string(ilayer - 51) + " in z+ "; + } + //--- + histograms.h_cellsnum_perthickperlayer[istr] = ibook.book1D("cellsnum_perthick_perlayer_"+istr,"total number of cells for layer "+ istr3+" for thickness "+istr1,nintTotNcellsperthickperlayer_,minTotNcellsperthickperlayer_,maxTotNcellsperthickperlayer_); + //--- + histograms.h_distancetoseedcell_perthickperlayer[istr] = ibook.book1D("distancetoseedcell_perthickperlayer_"+istr,"distance of cluster cells to seed cell for layer "+ istr3+" for thickness "+istr1,nintDisToSeedperthickperlayer_,minDisToSeedperthickperlayer_,maxDisToSeedperthickperlayer_); + //--- + histograms.h_distancetoseedcell_perthickperlayer_eneweighted[istr] = ibook.book1D("distancetoseedcell_perthickperlayer_eneweighted_"+istr,"energy weighted distance of cluster cells to seed cell for layer "+ istr3+" for thickness "+istr1,nintDisToSeedperthickperlayerenewei_,minDisToSeedperthickperlayerenewei_,maxDisToSeedperthickperlayerenewei_); + //--- + histograms.h_distancetomaxcell_perthickperlayer[istr] = ibook.book1D("distancetomaxcell_perthickperlayer_"+istr,"distance of cluster cells to max cell for layer "+ istr3+" for thickness "+istr1,nintDisToMaxperthickperlayer_,minDisToMaxperthickperlayer_,maxDisToMaxperthickperlayer_); + //--- + histograms.h_distancetomaxcell_perthickperlayer_eneweighted[istr] = ibook.book1D("distancetomaxcell_perthickperlayer_eneweighted_"+istr,"energy weighted distance of cluster cells to max cell for layer "+ istr3+" for thickness "+istr1,nintDisToMaxperthickperlayerenewei_,minDisToMaxperthickperlayerenewei_,maxDisToMaxperthickperlayerenewei_); + //--- + histograms.h_distancebetseedandmaxcell_perthickperlayer[istr] = ibook.book1D("distancebetseedandmaxcell_perthickperlayer_"+istr,"distance of seed cell to max cell for layer "+ istr3+" for thickness "+istr1,nintDisSeedToMaxperthickperlayer_,minDisSeedToMaxperthickperlayer_,maxDisSeedToMaxperthickperlayer_); + //--- + histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer[istr] = ibook.book2D("distancebetseedandmaxcellvsclusterenergy_perthickperlayer_"+istr,"distance of seed cell to max cell vs cluster energy for layer "+ istr3+" for thickness "+istr1,nintDisSeedToMaxperthickperlayer_,minDisSeedToMaxperthickperlayer_,maxDisSeedToMaxperthickperlayer_,nintClEneperthickperlayer_,minClEneperthickperlayer_,maxClEneperthickperlayer_); + + } + } + //--------------------------------------------------------------------------------------------------------------------------- + +} + +void HGVHistoProducerAlgo::fill_info_histos(const Histograms& histograms, unsigned layers) const { + + //We will save some info straight from geometry to avoid mistakes from updates + //----------- TODO ---------------------------------------------------------- + //For now values returned for 'lastLayerFHzp': '104', 'lastLayerFHzm': '52' are not the one expected. + //Will come back to this when there will be info in CMSSW to put in DQM file. + histograms.lastLayerEEzm.fill( recHitTools_->lastLayerEE() ); + histograms.lastLayerFHzm.fill( recHitTools_->lastLayerFH() ); + histograms.maxlayerzm.fill( layers ); + histograms.lastLayerEEzp.fill( recHitTools_->lastLayerEE() + layers ); + histograms.lastLayerFHzp.fill( recHitTools_->lastLayerFH() + layers); + histograms.maxlayerzp.fill( layers + layers); + +} + + +void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms, + int pdgid, + const CaloParticle & caloparticle, + std::vector const & simVertices) const { + + const auto eta = getEta(caloparticle.eta()); + if (histograms.h_caloparticle_eta.count(pdgid)){ histograms.h_caloparticle_eta.at(pdgid).fill(eta); } + if (histograms.h_caloparticle_eta_Zorigin.count(pdgid)){ histograms.h_caloparticle_eta_Zorigin.at(pdgid).fill( simVertices.at(caloparticle.g4Tracks()[0].vertIndex()).position().z(), eta ); } + + if (histograms.h_caloparticle_energy.count(pdgid)){ histograms.h_caloparticle_energy.at(pdgid).fill( caloparticle.energy() ); } + if (histograms.h_caloparticle_pt.count(pdgid)){ histograms.h_caloparticle_pt.at(pdgid).fill( caloparticle.pt() ); } + if (histograms.h_caloparticle_phi.count(pdgid)){ histograms.h_caloparticle_phi.at(pdgid).fill( caloparticle.phi() ); } + + +} + +void HGVHistoProducerAlgo::fill_cluster_histos(const Histograms& histograms, + int count, + const reco::CaloCluster & cluster) const { + + const auto eta = getEta(cluster.eta()); + histograms.h_cluster_eta[count].fill(eta); +} + +void HGVHistoProducerAlgo::layerClusters_to_CaloParticles (const Histograms& histograms, + const reco::CaloClusterCollection &clusters, + std::vector const & cP, + std::map const & hitMap, + unsigned layers) const +{ + + auto nLayerClusters = clusters.size(); + auto nCaloParticles = cP.size(); + + std::unordered_map > detIdToCaloParticleId_Map; + std::unordered_map > detIdToLayerClusterId_Map; + + // this contains the ids of the caloparticles contributing with at least one hit to the layer cluster and the reconstruction error + std::vector > > cpsInLayerCluster; + cpsInLayerCluster.resize(nLayerClusters); + + + + std::vector > cPOnLayer; + cPOnLayer.resize(nCaloParticles); + for(unsigned int i = 0; i< nCaloParticles; ++i) + { + cPOnLayer[i].resize(layers*2); + for(unsigned int j = 0; j< layers*2; ++j) + { + cPOnLayer[i][j].caloParticleId = i; + cPOnLayer[i][j].energy = 0.f; + cPOnLayer[i][j].hits_and_fractions.clear(); + } + } + + for(unsigned int cpId =0; cpId < nCaloParticles; ++cpId) + { + const SimClusterRefVector& simClusterRefVector = cP[cpId].simClusters(); + for (const auto& it_sc : simClusterRefVector) { + const SimCluster& simCluster = (*(it_sc)); + const auto& hits_and_fractions = simCluster.hits_and_fractions(); + for (const auto& it_haf : hits_and_fractions) { + DetId hitid = (it_haf.first); + int cpLayerId = recHitTools_->getLayerWithOffset(hitid) + layers * ((recHitTools_->zside(hitid) + 1) >> 1) - 1; + std::map::const_iterator itcheck= hitMap.find(hitid); + if(itcheck != hitMap.end()) + { + const HGCRecHit *hit = itcheck->second; + auto hit_find_it = detIdToCaloParticleId_Map.find(hitid); + if (hit_find_it == detIdToCaloParticleId_Map.end()) + { + detIdToCaloParticleId_Map[hitid] = std::vector (); + detIdToCaloParticleId_Map[hitid].emplace_back(HGVHistoProducerAlgo::detIdInfoInCluster{cpId,it_haf.second}); + } + else + { + auto findHitIt = std::find(detIdToCaloParticleId_Map[hitid].begin(), detIdToCaloParticleId_Map[hitid].end(), HGVHistoProducerAlgo::detIdInfoInCluster{cpId,it_haf.second}) ; + if( findHitIt != detIdToCaloParticleId_Map[hitid].end() ) + { + findHitIt->fraction +=it_haf.second; + } + else + { + detIdToCaloParticleId_Map[hitid].emplace_back(HGVHistoProducerAlgo::detIdInfoInCluster{cpId,it_haf.second}); + } + } + cPOnLayer[cpId][cpLayerId].energy += it_haf.second*hit->energy(); + cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid,it_haf.second); + } + } + } + } + + + for (unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) + { + const std::vector >& hits_and_fractions = clusters[lcId].hitsAndFractions(); + unsigned int numberOfHitsInLC = hits_and_fractions.size(); + + std::vector hitsToCaloParticleId(numberOfHitsInLC); + const auto firstHitDetId = hits_and_fractions[0].first; + int lcLayerId = recHitTools_->getLayerWithOffset(firstHitDetId) + layers * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; + + int maxCPId_byNumberOfHits = -1; + unsigned int maxCPNumberOfHitsInLC = 0; + int maxCPId_byEnergy = -1; + float maxEnergySharedLCandCP = 0.f; + float energyFractionOfLCinCP = 0.f; + float energyFractionOfCPinLC = 0.f; + std::unordered_map occurrencesCPinLC; + std::unordered_map CPEnergyInLC; + unsigned int numberOfNoiseHitsInLC = 0; + unsigned int numberOfHaloHitsInLC = 0; + + for (unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) + { + DetId rh_detid = hits_and_fractions[hitId].first; + auto rhFraction = hits_and_fractions[hitId].second; + + std::map::const_iterator itcheck= hitMap.find(rh_detid); + const HGCRecHit *hit = itcheck->second; + + + auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid); + if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) + { + detIdToLayerClusterId_Map[rh_detid] = std::vector (); + } + detIdToLayerClusterId_Map[rh_detid].emplace_back(HGVHistoProducerAlgo::detIdInfoInCluster{lcId,rhFraction}); + + auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid); + + // if the fraction is zero or the hit does not belong to any calo + // particle, set the caloparticleId for the hit to -1 this will + // contribute to the number of noise hits + + // MR Remove the case in which the fraction is 0, since this could be a + // real hit that has been marked as halo. + if (rhFraction == 0.) { + hitsToCaloParticleId[hitId] = -2; + numberOfHaloHitsInLC++; + } + if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) + { + hitsToCaloParticleId[hitId] -= 1; + } + else + { + auto maxCPEnergyInLC = 0.f; + auto maxCPId = -1; + for(auto& h: hit_find_in_CP->second) + { + CPEnergyInLC[h.clusterId] += h.fraction*hit->energy(); + cPOnLayer[h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].first += h.fraction*hit->energy(); + cpsInLayerCluster[lcId].emplace_back(std::make_pair(h.clusterId, 0.f)); + if(h.fraction >maxCPEnergyInLC) + { + maxCPEnergyInLC = CPEnergyInLC[h.clusterId]; + maxCPId = h.clusterId; + } + } + hitsToCaloParticleId[hitId] = maxCPId; + } + histograms.h_cellAssociation_perlayer.at(lcLayerId%52+1).fill(hitsToCaloParticleId[hitId] > 0. ? 0. : hitsToCaloParticleId[hitId]); + } + + for(auto& c: hitsToCaloParticleId) + { + if(c < 0) + { + numberOfNoiseHitsInLC++; + } + else + { + occurrencesCPinLC[c]++; + } + } + + for(auto&c : occurrencesCPinLC) + { + if(c.second > maxCPNumberOfHitsInLC) + { + maxCPId_byNumberOfHits = c.first; + maxCPNumberOfHitsInLC = c.second; + } + } + + for(auto&c : CPEnergyInLC) + { + if(c.second > maxEnergySharedLCandCP) + { + maxCPId_byEnergy = c.first; + maxEnergySharedLCandCP = c.second; + } + } + float totalCPEnergyOnLayer = 0.f; + if(maxCPId_byEnergy >=0) { + totalCPEnergyOnLayer = cPOnLayer[maxCPId_byEnergy][lcLayerId].energy; + energyFractionOfCPinLC = maxEnergySharedLCandCP/totalCPEnergyOnLayer; + if(clusters[lcId].energy()>0.f) + { + energyFractionOfLCinCP = maxEnergySharedLCandCP/clusters[lcId].energy(); + } + } + LogDebug("HGCalValidator") << std::setw(10) << "LayerId:"<< "\t" + << std::setw(12) << "layerCluster"<< "\t" + << std::setw(10) << "lc energy"<< "\t" + << std::setw(5) << "nhits" << "\t" + << std::setw(12) << "noise hits" << "\t" + << std::setw(22) << "maxCPId_byNumberOfHits" << "\t" + << std::setw(8) << "nhitsCP"<< "\t" + << std::setw(16) << "maxCPId_byEnergy" << "\t" + << std::setw(23) << "maxEnergySharedLCandCP" << "\t" + << std::setw(22) << "totalCPEnergyOnLayer" << "\t" + << std::setw(22) << "energyFractionOfLCinCP" << "\t" + << std::setw(25) << "energyFractionOfCPinLC" << "\t" << "\n"; + LogDebug("HGCalValidator") << std::setw(10) << lcLayerId << "\t" + << std::setw(12) << lcId << "\t" + << std::setw(10) << clusters[lcId].energy()<< "\t" + << std::setw(5) << numberOfHitsInLC << "\t" + << std::setw(12) << numberOfNoiseHitsInLC << "\t" + << std::setw(22) << maxCPId_byNumberOfHits << "\t" + << std::setw(8) << maxCPNumberOfHitsInLC<< "\t" + << std::setw(16) << maxCPId_byEnergy << "\t" + << std::setw(23) << maxEnergySharedLCandCP << "\t" + << std::setw(22) << totalCPEnergyOnLayer << "\t" + << std::setw(22) << energyFractionOfLCinCP << "\t" + << std::setw(25) << energyFractionOfCPinLC << "\n"; + } + + for (unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) + { + // find the unique caloparticles id contributing to the layer clusters + std::sort(cpsInLayerCluster[lcId].begin(), cpsInLayerCluster[lcId].end()); + auto last = std::unique(cpsInLayerCluster[lcId].begin(), cpsInLayerCluster[lcId].end()); + cpsInLayerCluster[lcId].erase(last, cpsInLayerCluster[lcId].end()); + const std::vector >& hits_and_fractions = clusters[lcId].hitsAndFractions(); + unsigned int numberOfHitsInLC = hits_and_fractions.size(); + auto firstHitDetId = hits_and_fractions[0].first; + int lcLayerId = recHitTools_->getLayerWithOffset(firstHitDetId) + layers * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1; + if (clusters[lcId].energy() == 0. && !cpsInLayerCluster[lcId].empty()) { + for(auto& cpPair : cpsInLayerCluster[lcId]) { + cpPair.second = 1.; + LogDebug("HGCalValidator") << "layerCluster Id: \t" << lcId + << "\t CP id: \t" << cpPair.first + << "\t score \t" << cpPair.second + << "\n"; + histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId%52+1).fill(cpPair.second); + } + continue; + } + float invLayerClusterEnergyWeight = 1.f/(clusters[lcId].energy()*clusters[lcId].energy()); + for(unsigned int i = 0; i < numberOfHitsInLC; ++i) + { + DetId rh_detid = hits_and_fractions[i].first; + float rhFraction = hits_and_fractions[i].second; + bool hitWithNoCP = false; + + auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid); + if(hit_find_in_CP == detIdToCaloParticleId_Map.end()) hitWithNoCP = true; + auto itcheck= hitMap.find(rh_detid); + const HGCRecHit *hit = itcheck->second; + float hitEnergyWeight = hit->energy()*hit->energy(); + + for(auto& cpPair : cpsInLayerCluster[lcId]) + { + float cpFraction = 0.f; + if(!hitWithNoCP) + { + auto findHitIt = std::find(detIdToCaloParticleId_Map[rh_detid].begin(), detIdToCaloParticleId_Map[rh_detid].end(), HGVHistoProducerAlgo::detIdInfoInCluster{cpPair.first,0.f}); + if(findHitIt != detIdToCaloParticleId_Map[rh_detid].end()) + cpFraction = findHitIt->fraction; + } + cpPair.second += (rhFraction - cpFraction)*(rhFraction - cpFraction)*hitEnergyWeight*invLayerClusterEnergyWeight; + } + } + + if(cpsInLayerCluster[lcId].empty()) LogDebug("HGCalValidator") << "layerCluster Id: \t" << lcId << "\tCP id:\t-1 " << "\t score \t-1" <<"\n"; + + for(auto& cpPair : cpsInLayerCluster[lcId]) + { + LogDebug("HGCalValidator") << "layerCluster Id: \t" << lcId + << "\t CP id: \t" << cpPair.first + << "\t score \t" << cpPair.second + << "\n"; + histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId).fill(cpPair.second); + auto const & cp_linked = cPOnLayer[cpPair.first][lcLayerId].layerClusterIdToEnergyAndScore[lcId]; + histograms.h_sharedenergy_layercl2caloparticle_perlayer.at(lcLayerId).fill(cp_linked.first/clusters[lcId].energy()); + histograms.h_energy_vs_score_layercl2caloparticle_perlayer.at(lcLayerId).fill(cpPair.second > 1. ? 1. : cpPair.second, cp_linked.first/clusters[lcId].energy()); + } + + auto assoc = std::count_if( + std::begin(cpsInLayerCluster[lcId]), + std::end(cpsInLayerCluster[lcId]), + [](const auto &obj){return obj.second < ScoreCutLCtoCP_;}); + if (assoc) { + histograms.h_num_layercl_eta_perlayer.at(lcLayerId).fill(clusters[lcId].eta()); + histograms.h_num_layercl_phi_perlayer.at(lcLayerId).fill(clusters[lcId].phi()); + if (assoc > 1) { + histograms.h_numMerge_layercl_eta_perlayer.at(lcLayerId).fill(clusters[lcId].eta()); + histograms.h_numMerge_layercl_phi_perlayer.at(lcLayerId).fill(clusters[lcId].phi()); + } + auto best = std::min_element( + std::begin(cpsInLayerCluster[lcId]), + std::end(cpsInLayerCluster[lcId]), + [](const auto &obj1, const auto &obj2){return obj1.second < obj2.second;}); + auto const & best_cp_linked = cPOnLayer[best->first][lcLayerId].layerClusterIdToEnergyAndScore[lcId]; + histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer.at(lcLayerId).fill(clusters[lcId].eta(), best_cp_linked.first/clusters[lcId].energy()); + histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer.at(lcLayerId).fill(clusters[lcId].phi(), best_cp_linked.first/clusters[lcId].energy()); + } + histograms.h_denom_layercl_eta_perlayer.at(lcLayerId).fill(clusters[lcId].eta()); + histograms.h_denom_layercl_phi_perlayer.at(lcLayerId).fill(clusters[lcId].phi()); + } + + + + for(unsigned int cpId =0; cpId < nCaloParticles; ++cpId) + { + + for(unsigned int layerId = 0; layerId< layers*2; ++layerId) + { + unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size(); + float CPenergy = cPOnLayer[cpId][layerId].energy; + if(CPNumberOfHits==0) continue; + int lcWithMaxEnergyInCP = -1; + float maxEnergyLCinCP = 0.f; + float CPEnergyFractionInLC = 0.f; + for(auto& lc : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) + { + if(lc.second.first > maxEnergyLCinCP) + { + maxEnergyLCinCP = lc.second.first; + lcWithMaxEnergyInCP = lc.first; + } + } + if(CPenergy >0.f) CPEnergyFractionInLC = maxEnergyLCinCP/CPenergy; + + LogDebug("HGCalValidator") << std::setw(8) << "LayerId:\t" + << std::setw(12) << "caloparticle\t" + << std::setw(15) << "cp total energy\t" + << std::setw(15) << "cpEnergyOnLayer\t" + << std::setw(14) << "CPNhitsOnLayer\t" + << std::setw(18) << "lcWithMaxEnergyInCP\t" + << std::setw(15) << "maxEnergyLCinCP\t" + << std::setw(20) << "CPEnergyFractionInLC" << "\n"; + LogDebug("HGCalValidator") << std::setw(8) << layerId << "\t" + << std::setw(12) << cpId << "\t" + << std::setw(15) << cP[cpId].energy() << "\t" + << std::setw(15) << CPenergy << "\t" + << std::setw(14) << CPNumberOfHits << "\t" + << std::setw(18) << lcWithMaxEnergyInCP << "\t" + << std::setw(15) << maxEnergyLCinCP << "\t" + << std::setw(20) << CPEnergyFractionInLC << "\n"; + + for(unsigned int i=0; i< CPNumberOfHits; ++i) + { + auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[i].first; + auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[i].second; + + + bool hitWithNoLC = false; + if(cpFraction ==0.f) continue; //hopefully this should never happen + auto hit_find_in_LC = detIdToLayerClusterId_Map.find(cp_hitDetId); + if(hit_find_in_LC == detIdToLayerClusterId_Map.end()) hitWithNoLC = true; + auto itcheck= hitMap.find(cp_hitDetId); + const HGCRecHit *hit = itcheck->second; + float hitEnergyWeight = hit->energy()*hit->energy(); + float invCPEnergyWeight = 1.f/(CPenergy*CPenergy); + for(auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) + { + unsigned int layerClusterId = lcPair.first; + float lcFraction = 0.f; + + if(!hitWithNoLC) + { + auto findHitIt = std::find( + detIdToLayerClusterId_Map[cp_hitDetId].begin(), + detIdToLayerClusterId_Map[cp_hitDetId].end(), + HGVHistoProducerAlgo::detIdInfoInCluster{layerClusterId, 0.f} + ); + if(findHitIt != detIdToLayerClusterId_Map[cp_hitDetId].end()) + lcFraction = findHitIt->fraction; + } + if (lcFraction == 0.) { + lcFraction = -1.; + } + lcPair.second.second += (lcFraction - cpFraction)*(lcFraction - cpFraction)*hitEnergyWeight*invCPEnergyWeight; + LogDebug("HGCalValidator") << "layerClusterId:\t" << layerClusterId << "\t" + << "lcfraction,cpfraction:\t" << lcFraction << ", " << cpFraction << "\t" + << "hitEnergyWeight:\t" << hitEnergyWeight << "\t" + << "currect score:\t" << lcPair.second.second << "\t" + << "invCPEnergyWeight:\t" << invCPEnergyWeight << "\n"; + } + } + + + + if(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty()) + LogDebug("HGCalValidator") << "CP Id: \t" << cpId << "\tLC id:\t-1 " << "\t score \t-1" <<"\n"; + + for(auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) + { + LogDebug("HGCalValidator") << "CP Id: \t" << cpId << "\t LC id: \t" + << lcPair.first << "\t score \t" + << lcPair.second.second << "\t" + << "shared energy:\t" << lcPair.second.first << "\t" + << "shared energy fraction:\t" << (lcPair.second.first/CPenergy) << "\n"; + histograms.h_score_caloparticle2layercl_perlayer.at(layerId).fill(lcPair.second.second > 1. ? 1. : lcPair.second.second); + histograms.h_sharedenergy_caloparticle2layercl_perlayer.at(layerId).fill(lcPair.second.first/CPenergy); + histograms.h_energy_vs_score_caloparticle2layercl_perlayer.at(layerId).fill(lcPair.second.second > 1. ? 1. : lcPair.second.second, lcPair.second.first/CPenergy); + } + auto assoc = std::count_if( + std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore), + std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore), + [](const auto &obj){return obj.second.second < ScoreCutCPtoLC_;}); + if (assoc) { + histograms.h_num_caloparticle_eta_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().eta()); + histograms.h_num_caloparticle_phi_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().phi()); + if (assoc > 1) { + histograms.h_numDup_caloparticle_eta_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().eta()); + histograms.h_numDup_caloparticle_phi_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().phi()); + } + auto best = std::min_element( + std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore), + std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore), + [](const auto &obj1, const auto &obj2){return obj1.second.second < obj2.second.second;}); + histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().eta(), best->second.first/CPenergy); + histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().phi(), best->second.first/CPenergy); + } + histograms.h_denom_caloparticle_eta_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().eta()); + histograms.h_denom_caloparticle_phi_perlayer.at(layerId).fill(cP[cpId].g4Tracks()[0].momentum().phi()); + } + } +} + +void HGVHistoProducerAlgo::fill_generic_cluster_histos(const Histograms& histograms, + int count, + const reco::CaloClusterCollection &clusters, + const Density &densities, + std::vector const & cP, + std::map const & hitMap, + std::map cummatbudg, + unsigned layers, + std::vector thicknesses) const { + + //Each event to be treated as two events: an event in +ve endcap, + //plus another event in -ve endcap. In this spirit there will be + //a layer variable (layerid) that maps the layers in : + //-z: 0->51 + //+z: 52->103 + + //To keep track of total num of layer clusters per layer + //tnlcpl[layerid] + std::vector tnlcpl(1000, 0); //tnlcpl.clear(); tnlcpl.reserve(1000); + + //To keep track of the total num of clusters per thickness in plus and in minus endcaps + std::map tnlcpthplus; tnlcpthplus.clear(); + std::map tnlcpthminus; tnlcpthminus.clear(); + //At the beginning of the event all layers should be initialized to zero total clusters per thickness + for(std::vector::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) { + tnlcpthplus.insert( std::pair(std::to_string(*it), 0) ); + tnlcpthminus.insert( std::pair(std::to_string(*it), 0) ); + } + //To keep track of the total num of clusters with mixed thickness hits per event + tnlcpthplus.insert( std::pair( "mixed", 0) ); + tnlcpthminus.insert( std::pair( "mixed", 0) ); + + layerClusters_to_CaloParticles(histograms, clusters, cP, hitMap, layers); + + //To find out the total amount of energy clustered per layer + //Initialize with zeros because I see clear gives weird numbers. + std::vector tecpl(1000, 0.0); //tecpl.clear(); tecpl.reserve(1000); + //for the longitudinal depth barycenter + std::vector ldbar(1000, 0.0); //ldbar.clear(); ldbar.reserve(1000); + + //We need to compare with the total amount of energy coming from caloparticles + double caloparteneplus = 0.; + double caloparteneminus = 0.; + for (auto const caloParticle : cP) { + if (caloParticle.eta() >= 0. ) {caloparteneplus = caloparteneplus + caloParticle.energy();} + if (caloParticle.eta() < 0. ) {caloparteneminus = caloparteneminus + caloParticle.energy();} + } + + //loop through clusters of the event + for (unsigned int layerclusterIndex = 0; layerclusterIndex < clusters.size(); layerclusterIndex++) { + + const std::vector > hits_and_fractions = clusters[layerclusterIndex].hitsAndFractions(); + + const DetId seedid = clusters[layerclusterIndex].seed(); + const double seedx = recHitTools_->getPosition(seedid).x(); + const double seedy = recHitTools_->getPosition(seedid).y(); + DetId maxid = findmaxhit( clusters[layerclusterIndex], hitMap ); + + // const DetId maxid = clusters[layerclusterIndex].max(); + double maxx = recHitTools_->getPosition(maxid).x(); + double maxy = recHitTools_->getPosition(maxid).y(); + + //Auxillary variables to count the number of different kind of hits in each cluster + int nthhits120p = 0; int nthhits200p = 0;int nthhits300p = 0;int nthhitsscintp = 0; + int nthhits120m = 0; int nthhits200m = 0;int nthhits300m = 0;int nthhitsscintm = 0; + //For the hits thickness of the layer cluster. + double thickness = 0.; + //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. + int layerid = 0; + //We will need another layer variable for the longitudinal material budget file reading. + //In this case we need no distinction between -z and +z. + int lay = 0; + //We will need here to save the combination thick_lay + std::string istr = ""; + //boolean to check for the layer that the cluster belong to. Maybe later will check all the layer hits. + bool cluslay = true; + //zside that the current cluster belongs to. + int zside = 0; + + for (std::vector>::const_iterator it_haf = hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) { + const DetId rh_detid = it_haf->first; + //The layer that the current hit belongs to + layerid = recHitTools_->getLayerWithOffset(rh_detid) + layers * ((recHitTools_->zside(rh_detid) + 1) >> 1) - 1; + lay = recHitTools_->getLayerWithOffset(rh_detid); + zside = recHitTools_->zside(rh_detid); + if (rh_detid.det() == DetId::Forward || rh_detid.det() == DetId::HGCalEE || rh_detid.det() == DetId::HGCalHSi){ + thickness = recHitTools_->getSiThickness(rh_detid); + } else if (rh_detid.det() == DetId::HGCalHSc){ + thickness = -1; + } else { + LogDebug("HGCalValidator") << "These are HGCal layer clusters, you shouldn't be here !!! " << layerid << "\n"; + continue; + } + + //Count here only once the layer cluster and save the combination thick_layerid + std::string curistr = std::to_string( (int) thickness ); + std::string lay_string = std::to_string(layerid); + while(lay_string.size() < 2) + lay_string.insert(0, "0"); + curistr += "_" + lay_string; + if (cluslay){ tnlcpl[layerid]++; istr = curistr; cluslay = false; } + + if ( (thickness == 120.) && (recHitTools_->zside(rh_detid) > 0. ) ) {nthhits120p++;} + else if ( (thickness == 120.) && (recHitTools_->zside(rh_detid) < 0. ) ) {nthhits120m++;} + else if ( (thickness == 200.) && (recHitTools_->zside(rh_detid) > 0. ) ) {nthhits200p++;} + else if ( (thickness == 200.) && (recHitTools_->zside(rh_detid) < 0. ) ) {nthhits200m++;} + else if ( (thickness == 300.) && (recHitTools_->zside(rh_detid) > 0. ) ) {nthhits300p++;} + else if ( (thickness == 300.) && (recHitTools_->zside(rh_detid) < 0. ) ) {nthhits300m++;} + else if ( (thickness == -1) && (recHitTools_->zside(rh_detid) > 0. ) ) {nthhitsscintp++;} + else if ( (thickness == -1) && (recHitTools_->zside(rh_detid) < 0. ) ) {nthhitsscintm++;} + else { //assert(0); + LogDebug("HGCalValidator") << " You are running a geometry that contains thicknesses different than the normal ones. " << "\n"; + } + + std::map::const_iterator itcheck= hitMap.find(rh_detid); + if (itcheck == hitMap.end()) { + LogDebug("HGCalValidator") << " You shouldn't be here - Unable to find a hit " << rh_detid.rawId() << " " << rh_detid.det() << " " << HGCalDetId(rh_detid) << "\n"; + continue; + } + + const HGCRecHit *hit = itcheck->second; + + //Here for the per cell plots + //---- + const double hit_x = recHitTools_->getPosition(rh_detid).x(); + const double hit_y = recHitTools_->getPosition(rh_detid).y(); + double distancetoseed = distance(seedx, seedy, hit_x, hit_y); + double distancetomax = distance(maxx, maxy, hit_x, hit_y); + if ( distancetoseed != 0. && histograms.h_distancetoseedcell_perthickperlayer.count(curistr)){ + histograms.h_distancetoseedcell_perthickperlayer.at(curistr).fill( distancetoseed ); + } + //---- + if ( distancetoseed != 0. && histograms.h_distancetoseedcell_perthickperlayer_eneweighted.count(curistr)){ + histograms.h_distancetoseedcell_perthickperlayer_eneweighted.at(curistr).fill( distancetoseed , hit->energy() ); } + //---- + if ( distancetomax != 0. && histograms.h_distancetomaxcell_perthickperlayer.count(curistr)){ + histograms.h_distancetomaxcell_perthickperlayer.at(curistr).fill( distancetomax ); } + //---- + if ( distancetomax != 0. && histograms.h_distancetomaxcell_perthickperlayer_eneweighted.count(curistr)){ + histograms.h_distancetomaxcell_perthickperlayer_eneweighted.at(curistr).fill( distancetomax , hit->energy() ); } + + //Let's check the density + std::map< DetId, float >::const_iterator dit = densities.find( rh_detid ); + if ( dit == densities.end() ){ + LogDebug("HGCalValidator") << " You shouldn't be here - Unable to find a density " << rh_detid.rawId() << " " << rh_detid.det() << " " << HGCalDetId(rh_detid) << "\n"; + continue; + } + + if ( histograms.h_cellsenedens_perthick.count( (int) thickness ) ){ + histograms.h_cellsenedens_perthick.at( (int) thickness ).fill( dit->second ); + } + + } // end of loop through hits and fractions + + //Check for simultaneously having hits of different kind. Checking at least two combinations is sufficient. + if ( (nthhits120p != 0 && nthhits200p != 0 ) || (nthhits120p != 0 && nthhits300p != 0 ) || (nthhits120p != 0 && nthhitsscintp != 0 ) || + (nthhits200p != 0 && nthhits300p != 0 ) || (nthhits200p != 0 && nthhitsscintp != 0 ) || (nthhits300p != 0 && nthhitsscintp != 0 ) ){ + tnlcpthplus["mixed"]++; + } else if ( (nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0) ) { + //This is a cluster with hits of one kind + tnlcpthplus[std::to_string((int) thickness)]++; + } + if ( (nthhits120m != 0 && nthhits200m != 0 ) || (nthhits120m != 0 && nthhits300m != 0 ) || (nthhits120m != 0 && nthhitsscintm != 0 ) || + (nthhits200m != 0 && nthhits300m != 0 ) || (nthhits200m != 0 && nthhitsscintm != 0 ) || (nthhits300m != 0 && nthhitsscintm != 0 ) ){ + tnlcpthminus["mixed"]++; + } else if ( (nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0) ) { + //This is a cluster with hits of one kind + tnlcpthminus[std::to_string((int) thickness)]++; + } + + //To find the thickness with the biggest amount of cells + std::vector bigamoth; bigamoth.clear(); + if (zside > 0 ){ + bigamoth.push_back(nthhits120p);bigamoth.push_back(nthhits200p);bigamoth.push_back(nthhits300p);bigamoth.push_back(nthhitsscintp); + } + if (zside < 0 ){ + bigamoth.push_back(nthhits120m);bigamoth.push_back(nthhits200m);bigamoth.push_back(nthhits300m);bigamoth.push_back(nthhitsscintm); + } + auto bgth = std::max_element(bigamoth.begin(),bigamoth.end()); + istr = std::to_string(thicknesses[ std::distance(bigamoth.begin(), bgth) ]); + std::string lay_string = std::to_string(layerid); + while(lay_string.size() < 2) + lay_string.insert(0, "0"); + istr += "_" + lay_string; + + //Here for the per cluster plots that need the thickness_layer info + if (histograms.h_cellsnum_perthickperlayer.count(istr)){ histograms.h_cellsnum_perthickperlayer.at(istr).fill( hits_and_fractions.size() ); } + + //Now, with the distance between seed and max cell. + double distancebetseedandmax = distance(seedx, seedy, maxx, maxy); + //The thickness_layer combination in this case will use the thickness of the seed as a convention. + std::string seedstr = std::to_string( (int) recHitTools_->getSiThickness(seedid) )+ "_" + std::to_string(layerid); + seedstr += "_" + lay_string; + if (histograms.h_distancebetseedandmaxcell_perthickperlayer.count(seedstr)){ + histograms.h_distancebetseedandmaxcell_perthickperlayer.at(seedstr).fill( distancebetseedandmax ); + } + if (histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.count(seedstr)){ + histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.at(seedstr).fill( distancebetseedandmax , clusters[layerclusterIndex].energy() ); + } + + //Energy clustered per layer + tecpl[layerid] = tecpl[layerid] + clusters[layerclusterIndex].energy(); + ldbar[layerid] = ldbar[layerid] + clusters[layerclusterIndex].energy() * cummatbudg[(double) lay]; + + }//end of loop through clusters of the event + + //After the end of the event we can now fill with the results. + //First a couple of variables to keep the sum of the energy of all clusters + double sumeneallcluspl = 0.; double sumeneallclusmi = 0.; + //And the longitudinal variable + double sumldbarpl = 0.; double sumldbarmi = 0.; + //Per layer : Loop 0->103 + for (unsigned ilayer = 0; ilayer < layers*2; ++ilayer) { + if (histograms.h_clusternum_perlayer.count(ilayer)){ + histograms.h_clusternum_perlayer.at(ilayer).fill( tnlcpl[ilayer] ); + } + // Two times one for plus and one for minus + //First with the -z endcap + if (ilayer < layers){ + if (histograms.h_energyclustered_perlayer.count(ilayer)){ + if ( caloparteneminus != 0.) { + histograms.h_energyclustered_perlayer.at(ilayer).fill( 100. * tecpl[ilayer]/caloparteneminus ); + } + } + //Keep here the total energy for the event in -z + sumeneallclusmi = sumeneallclusmi + tecpl[ilayer]; + //And for the longitudinal variable + sumldbarmi = sumldbarmi + ldbar[ilayer]; + } else { //Then for the +z + if (histograms.h_energyclustered_perlayer.count(ilayer)){ + if ( caloparteneplus != 0.) { + histograms.h_energyclustered_perlayer.at(ilayer).fill( 100. * tecpl[ilayer]/caloparteneplus ); + } + } + //Keep here the total energy for the event in -z + sumeneallcluspl = sumeneallcluspl + tecpl[ilayer]; + //And for the longitudinal variable + sumldbarpl = sumldbarpl + ldbar[ilayer]; + } //end of +z loop + + }//end of loop over layers + + //Per thickness + for(std::vector::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) { + if ( histograms.h_clusternum_perthick.count(*it) ){ + histograms.h_clusternum_perthick.at(*it).fill( tnlcpthplus[std::to_string(*it)] ); + histograms.h_clusternum_perthick.at(*it).fill( tnlcpthminus[std::to_string(*it)] ); + } + } + //Mixed thickness clusters + histograms.h_mixedhitscluster_zplus[count].fill( tnlcpthplus["mixed"] ); + histograms.h_mixedhitscluster_zminus[count].fill( tnlcpthminus["mixed"] ); + + //Total energy clustered from all layer clusters (fraction) + if ( caloparteneplus != 0.) {histograms.h_energyclustered_zplus[count].fill( 100. * sumeneallcluspl /caloparteneplus ); } + if ( caloparteneminus != 0.) {histograms.h_energyclustered_zminus[count].fill( 100. * sumeneallclusmi /caloparteneminus ); } + + //For the longitudinal depth barycenter + histograms.h_longdepthbarycentre_zplus[count].fill( sumldbarpl / sumeneallcluspl ); + histograms.h_longdepthbarycentre_zminus[count].fill( sumldbarmi / sumeneallclusmi ); + +} + +double HGVHistoProducerAlgo::distance2(const double x1, const double y1, const double x2, const double y2) const { //distance squared + const double dx = x1 - x2; + const double dy = y1 - y2; + return (dx*dx + dy*dy); +} //distance squaredq +double HGVHistoProducerAlgo::distance(const double x1, const double y1, const double x2, const double y2) const{ //2-d distance on the layer (x-y) + return std::sqrt(distance2(x1,y1,x2,y2) ); +} + +void HGVHistoProducerAlgo::setRecHitTools(std::shared_ptr recHitTools) { + recHitTools_ = recHitTools; +} + +DetId HGVHistoProducerAlgo::findmaxhit(const reco::CaloCluster & cluster, + std::map const & hitMap) const { + + DetId themaxid; + const std::vector >& hits_and_fractions = cluster.hitsAndFractions(); + + double maxene = 0.; + for (std::vector>::const_iterator it_haf = hits_and_fractions.begin(); it_haf != hits_and_fractions.end(); ++it_haf) { + DetId rh_detid = it_haf->first; + + std::map::const_iterator itcheck= hitMap.find(rh_detid); + const HGCRecHit *hit = itcheck->second; + + if ( maxene < hit->energy() ){ + maxene = hit->energy(); + themaxid = rh_detid; + } + + } + + return themaxid; +} + + +double HGVHistoProducerAlgo::getEta(double eta) const { + if (useFabsEta_) return fabs(eta); + else return eta; +} + diff --git a/Validation/HGCalValidation/test/HGCGeometryCheck.cc b/Validation/HGCalValidation/test/HGCGeometryCheck.cc index e01219ac4d114..50f7294a7722b 100644 --- a/Validation/HGCalValidation/test/HGCGeometryCheck.cc +++ b/Validation/HGCalValidation/test/HGCGeometryCheck.cc @@ -31,6 +31,8 @@ #include +//#define EDM_ML_DEBUG + class HGCGeometryCheck : public edm::one::EDAnalyzer { public: @@ -70,12 +72,13 @@ HGCGeometryCheck::HGCGeometryCheck(const edm::ParameterSet &cfg) : hcons_(0) { g4Token_ = consumes(cfg.getParameter("g4Source")); geometrySource_ = cfg.getUntrackedParameter< std::vector >("geometrySource"); - edm::LogVerbatim("HGCalValidation") << "HGCGeometryCheck:: use information from " - << cfg.getParameter("g4Source") << " and " - << geometrySource_.size() << " geometry records:"; + edm::LogVerbatim("HGCalValid") << "HGCGeometryCheck:: use information from " + << cfg.getParameter("g4Source") + << " and " + << geometrySource_.size() + << " geometry records:"; for (unsigned int k=0; k hgcGeom; iSetup.get().get(geometrySource_[i],hgcGeom); if (hgcGeom.isValid()) { hgcGeometry_.push_back(hgcGeom.product()); + edm::LogVerbatim("HGCalValid") << "Initialize geometry for " + << geometrySource_[i]; } else { edm::LogWarning("HGCalValid") << "Cannot initiate HGCalGeometry for " - << geometrySource_[i] << std::endl; + << geometrySource_[i]; } } } @@ -137,12 +144,13 @@ void HGCGeometryCheck::beginRun(const edm::Run&, const edm::EventSetup& iSetup) void HGCGeometryCheck::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - edm::LogVerbatim("HGCalValidation") << "HGCGeometryCheck::Run " - << iEvent.id().run() << " Event " - << iEvent.id().event() << " Luminosity " - << iEvent.luminosityBlock() << " Bunch " - << iEvent.bunchCrossing(); - +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "HGCGeometryCheck::Run " + << iEvent.id().run() << " Event " + << iEvent.id().event() << " Luminosity " + << iEvent.luminosityBlock() << " Bunch " + << iEvent.bunchCrossing(); +#endif //Accessing G4 information edm::Handle infoLayer; iEvent.getByToken(g4Token_,infoLayer); @@ -186,12 +194,14 @@ void HGCGeometryCheck::analyze(const edm::Event &iEvent, } double zp = hgcGeometry_[dtype]->waferZ(layer,true); //cm if (zside < 0) zp = -zp; - edm::LogVerbatim("HGCalValidation") << "Info[" << i - << "] Detector Information " - << hitDet[i] << ":" << subdet - << ":" << zside << ":" << layer - << " Z " << zp << ":" << zz - << " R " << rr; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "Info[" << i + << "] Detector Information " + << hitDet[i] << ":" << subdet + << ":" << zside << ":" << layer + << " Z " << zp << ":" << zz + << " R " << rr; +#endif if (dtype == 0) { heedzVsZ->Fill(zp, (zz-zp)); heezVsLayer->Fill(layer,zz); @@ -213,13 +223,15 @@ void HGCGeometryCheck::analyze(const edm::Event &iEvent, HcalCellType::HcalCell cell = hcons_->cell(subdet, zside, lay, eta, phi); double zp = cell.rz/10; //mm --> cm if (zside == 0) zp = -zp; - edm::LogVerbatim("HGCalValidation") << "Info[" << i - << "] Detector Information " - << hitDet[i] << ":" << subdet - << ":" << zside << ":" << depth - << ":" << eta << ":" << phi << ":" - << lay << " z " << zp << ":" - << zz << " R " << rr; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HGCalValid") << "Info[" << i + << "] Detector Information " + << hitDet[i] << ":" << subdet + << ":" << zside << ":" << depth + << ":" << eta << ":" << phi << ":" + << lay << " z " << zp << ":" + << zz << " R " << rr; +#endif hebdzVsZ->Fill(zp, (zz-zp)); hebzVsLayer->Fill(lay,zz); hebrVsLayer->Fill(lay,rr); diff --git a/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py b/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py index 7c33adc279f46..556654d3d63aa 100644 --- a/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py +++ b/Validation/HGCalValidation/test/runHGCGeomCheck_cfg.py @@ -1,34 +1,41 @@ - import FWCore.ParameterSet.Config as cms - -process = cms.Process("HGCGeomAnalysis") +from Configuration.StandardSequences.Eras import eras + +#process = cms.Process("HGCGeomAnalysis",eras.Phase2) +#process.load('Configuration.Geometry.GeometryExtended2023D21Reco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D21_cff') +#process = cms.Process("HGCGeomAnalysis",eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +process = cms.Process("HGCGeomAnalysis",eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') process.load('Configuration.StandardSequences.Services_cff') process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') - -##v7 Geometry, with hex cells -process.load('Configuration.Geometry.GeometryExtended2023D3Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2023D3_cff') -process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag -##Global Tag used for production in -## /uscms_data/d3/mhaytmyr/CMSSW_8_0_0_pre4/src/RecoLocalCalo/HGCalRecProducers/test/testHGCalRecoLocal_cfg.py -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('HGCalValid') + process.MessageLogger.categories.append('HGCalGeom') process.MessageLogger.cerr.FwkReport.reportEvery = 100 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( - 'file:testHGCalSimWatcher.root', + 'file:testHGCalSimWatcherV10.root', ) ) -process.load('Validation.HGCalValidation.hgcGeomCheck_cfi') +process.load('Validation.HGCalValidation.hgcGeomCheck_cff') process.TFileService = cms.Service("TFileService", - fileName = cms.string('hgcGeomCheck.root'), + fileName = cms.string('hgcGeomCheckV10.root'), closeFileFast = cms.untracked.bool(True) ) diff --git a/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py index f4cf8db7cdaa9..0ee11d07d4f7a 100644 --- a/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalDigiStudy_cfg.py @@ -1,11 +1,15 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('PROD',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') + +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") -process.load('Configuration.Geometry.GeometryExtended2023D28_cff') -process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') process.load("Configuration.StandardSequences.MagneticField_cff") process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.StandardSequences.RawToDigi_cff') @@ -14,8 +18,8 @@ from Configuration.AlCa.autoCond import autoCond process.GlobalTag.globaltag = autoCond['phase2_realistic'] -if hasattr(process,'MessageLogger'): - process.MessageLogger.categories.append('HGCalValidation') +#if hasattr(process,'MessageLogger'): +# process.MessageLogger.categories.append('HGCalValidation') process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring( diff --git a/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py index df908aa72cf5d..16ba54e018a08 100644 --- a/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalRecHitStudy_cfg.py @@ -2,14 +2,19 @@ import FWCore.Utilities.FileUtils as FileUtils from Configuration.StandardSequences.Eras import eras -process = cms.Process('HGCGeomAnalysis',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') +#process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') + +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") +process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('FWCore.MessageService.MessageLogger_cfi') process.load('Configuration.EventContent.EventContent_cff') -process.load('Configuration.Geometry.GeometryExtended2023D28Reco_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') from Configuration.AlCa.GlobalTag import GlobalTag @@ -34,7 +39,7 @@ process.hgcalRecHitStudyBH.Verbosity = 0 process.TFileService = cms.Service("TFileService", - fileName = cms.string('rechitStudy.root'), + fileName = cms.string('hgcRecHit.root'), closeFileFast = cms.untracked.bool(True) ) diff --git a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py index 46d4ac61900df..17ae86564f9d5 100644 --- a/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py +++ b/Validation/HGCalValidation/test/runHGCalSimHitStudy_cfg.py @@ -1,14 +1,14 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -process = cms.Process('PROD',eras.Phase2C4) +#process = cms.Process('PROD',eras.Phase2C4) +#process.load('Configuration.Geometry.GeometryExtended2023D28_cff') + +process = cms.Process('PROD',eras.Phase2C4_timing_layer_bar) +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") -process.load('Configuration.Geometry.GeometryExtended2023D28_cff') -#process.load("Geometry.HGCalCommonData.testHGCV9XML_cfi") -#process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi") -#process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi") process.load("Configuration.StandardSequences.MagneticField_cff") process.load("Configuration.EventContent.EventContent_cff") process.load('Configuration.StandardSequences.Generator_cff') @@ -19,10 +19,10 @@ from Configuration.AlCa.autoCond import autoCond process.GlobalTag.globaltag = autoCond['phase2_realistic'] -if hasattr(process,'MessageLogger'): - process.MessageLogger.categories.append('HGCalGeom') - process.MessageLogger.categories.append('HGCSim') - process.MessageLogger.categories.append('HGCalValidation') +#if hasattr(process,'MessageLogger'): +# process.MessageLogger.categories.append('HGCalGeom') +# process.MessageLogger.categories.append('HGCSim') +# process.MessageLogger.categories.append('HGCalValidation') process.load("IOMC.RandomEngine.IOMC_cff") process.RandomNumberGeneratorService.generator.initialSeed = 456789 diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py new file mode 100644 index 0000000000000..252c238725504 --- /dev/null +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV10_cfg.py @@ -0,0 +1,153 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('testHGCalRecoLocal',eras.Phase2C4_timing_layer_bar) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2023D41Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2023D41_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.DigiToRaw_cff') +process.load('HLTrigger.Configuration.HLT_Fake2_cff') +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.load('Configuration.StandardSequences.L1Reco_cff') +process.load('Configuration.StandardSequences.Reconstruction_cff') +process.load('Configuration.StandardSequences.RecoSim_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000) +) + +process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + version = cms.untracked.string(''), + annotation = cms.untracked.string(''), + name = cms.untracked.string('Applications') +) + + +# Output definition +process.output = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = cms.untracked.vstring( + 'keep *_*hbhe*_*_*', + 'keep *_g4SimHits_*_*', +# 'keep *_mix_*_*', + 'keep *_*HGC*_*_*', + ), + fileName = cms.untracked.string('file:testHGCalSimWatcherV10.root'), + dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW-RECO') + ), + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ) +) + +# Additional output definition +process.g4SimHits.Watchers = cms.VPSet(cms.PSet( + SimG4HGCalValidation = cms.PSet( + Names = cms.vstring( + 'HGCalEESensitive', + 'HGCalHESensitive', + 'HGCalHESiliconSensitive', + 'HGCalHEScintillatorSensitive', + ), + Types = cms.vint32(0,0,0,0), + DetTypes = cms.vint32(0,1,1,2), + LabelLayerInfo = cms.string("HGCalInfoLayer"), + Verbosity = cms.untracked.int32(0), + ), + type = cms.string('SimG4HGCalValidation') +)) + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + PGunParameters = cms.PSet( + MaxPt = cms.double(20.0), + MinPt = cms.double(20.0), + #PartID = cms.vint32(11), #--->electron + PartID = cms.vint32(13), #--->muon + #PartID = cms.vint32(211), #--->pion + MaxEta = cms.double(3.0), + MaxPhi = cms.double(3.14159265359), + MinEta = cms.double(1.2), + MinPhi = cms.double(-3.14159265359) + ), + Verbosity = cms.untracked.int32(0), + psethack = cms.string('single muon pt 35'), + AddAntiParticle = cms.bool(False), + firstRun = cms.untracked.uint32(1) +) + + +#Modified to produce hgceedigis +process.mix.digitizers = cms.PSet(process.theDigitizersValid) + +process.ProductionFilterSequence = cms.Sequence(process.generator) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.digitisation_step = cms.Path(process.pdigi_valid) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.digi2raw_step = cms.Path(process.DigiToRaw) +process.raw2digi_step = cms.Path(process.RawToDigi) +process.L1Reco_step = cms.Path(process.L1Reco) +process.reconstruction_step = cms.Path(process.localreco) +process.recosim_step = cms.Path(process.recosim) +process.out_step = cms.EndPath(process.output) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step, + process.simulation_step, + process.digitisation_step, + process.L1simulation_step, + process.L1TrackTrigger_step, + process.digi2raw_step, +# process.HLTSchedule, + process.raw2digi_step, + process.L1Reco_step, + process.reconstruction_step, + process.recosim_step, + process.out_step + ) + +# filter all path with the production filter sequence +for path in process.paths: + if getattr(process,path)._seq is not None: getattr(process,path)._seq = process.ProductionFilterSequence * getattr(process,path)._seq diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py index 3932b9296037b..bfc390bf4b3df 100644 --- a/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV8_cfg.py @@ -32,6 +32,10 @@ ) process.MessageLogger.cerr.FwkReport.reportEvery = 5 +if hasattr(process,'MessageLogger'): + process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') + # Input source process.source = cms.Source("EmptySource") @@ -54,7 +58,7 @@ outputCommands = cms.untracked.vstring( 'keep *_*hbhe*_*_*', 'keep *_g4SimHits_*_*', - 'keep *_mix_*_*', +# 'keep *_mix_*_*', 'keep *_*HGC*_*_*', ), fileName = cms.untracked.string('file:testHGCalSimWatcherV8.root'), @@ -67,17 +71,6 @@ ) ) -process.MessageLogger = cms.Service("MessageLogger", - cout = cms.untracked.PSet( - default = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), -# ValidHGCal = cms.untracked.PSet(limit = cms.untracked.int32(0)), - ), -# categories = cms.untracked.vstring('ValidHGCal'), - destinations = cms.untracked.vstring('cout','cerr') -) - # Additional output definition process.g4SimHits.Watchers = cms.VPSet(cms.PSet( SimG4HGCalValidation = cms.PSet( diff --git a/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py b/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py index 42f7879b96ea4..5e188284284e3 100644 --- a/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py +++ b/Validation/HGCalValidation/test/testHGCalSimWatcherV9_cfg.py @@ -33,8 +33,10 @@ input = cms.untracked.int32(1000) ) +process.MessageLogger.cerr.FwkReport.reportEvery = 5 if hasattr(process,'MessageLogger'): process.MessageLogger.categories.append('ValidHGCal') + process.MessageLogger.categories.append('HGCalGeom') # Input source process.source = cms.Source("EmptySource") @@ -58,7 +60,7 @@ outputCommands = cms.untracked.vstring( 'keep *_*hbhe*_*_*', 'keep *_g4SimHits_*_*', - 'keep *_mix_*_*', +# 'keep *_mix_*_*', 'keep *_*HGC*_*_*', ), fileName = cms.untracked.string('file:testHGCalSimWatcherV9.root'), diff --git a/Validation/HcalDigis/src/HcalDigisValidation.cc b/Validation/HcalDigis/src/HcalDigisValidation.cc index 88b8a1a8e675c..f29d8e4628055 100644 --- a/Validation/HcalDigis/src/HcalDigisValidation.cc +++ b/Validation/HcalDigis/src/HcalDigisValidation.cc @@ -600,7 +600,6 @@ template void HcalDigisValidation::reco(const edm::Event& iEvent, co typename edm::SortedCollection::const_iterator digiItr; // ADC2fC - HcalCalibrations calibrations; CaloSamples tool; iEvent.getByToken(tok, digiCollection); if (!digiCollection.isValid()) return; @@ -896,7 +895,6 @@ template void HcalDigisValidation::reco(const edm::Event& i // ADC2fC - HcalCalibrations calibrations; CaloSamples tool; iEvent.getByToken(tok, digiHandle); if (!digiHandle.isValid()) return; diff --git a/Validation/RecoMuon/test/macro/new_PlotHelpers.C b/Validation/RecoMuon/test/macro/new_PlotHelpers.C index d4a071ccfc6ed..82a36e9b4cd9f 100644 --- a/Validation/RecoMuon/test/macro/new_PlotHelpers.C +++ b/Validation/RecoMuon/test/macro/new_PlotHelpers.C @@ -754,13 +754,18 @@ TH1* AddOverflow(TH1* h) { ++overflowCounter; TString name = h->GetName(); - Int_t nx = h->GetNbinsX()+1; - Double_t bw = h->GetBinWidth(nx); + const Int_t nx = h->GetNbinsX(); Double_t x1 = h->GetBinLowEdge(1); - Double_t x2 = h->GetBinLowEdge(nx) + bw; - - // Book a new histogram having an extra bin for overflows - TH1F* htmp = new TH1F(Form(name + "_overflow_%d", overflowCounter), "", nx, x1, x2); + + Double_t xbins[nx+1]; + + //Loop necessary since some histograms are TH1 while some are TProfile and do not allow us to use the clone function (SetBinContent do not exists for TProfiles) + for (Int_t ibin=1; ibin<=nx+1; ibin++) { + Float_t xmin = h->GetBinLowEdge(ibin); + xbins[ibin-1] = xmin; + } + + TH1F* htmp = new TH1F(Form(name + "_overflow_%d", overflowCounter), "", nx, xbins); // Fill the new histogram including the extra bin for overflows for (Int_t i=1; i<=nx; i++) { diff --git a/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C b/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C index e15381da0eabf..df60cacfbe5af 100644 --- a/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C +++ b/Validation/RecoMuon/test/macro/new_TrackValHistoPublisher.C @@ -177,9 +177,9 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi miny[3]=-0.0001; maxy[0]=1.09; - maxy[1]=0.; + maxy[1]=1.09; maxy[2]=1.09; - maxy[3]=0.; + maxy[3]=1.09; Plot4Histograms(newDir + "/eff_eta_phi", rdir, sdir, @@ -218,7 +218,7 @@ void new_TrackValHistoPublisher(const char* newFile="NEW_FILE",const char* refFi miny[3]= 0.; maxy[0]= 1.09; - maxy[1]= 0.; + maxy[1]= 1.09; maxy[2]= 0.; maxy[3]= 0.; diff --git a/Validation/RecoMuon/test/new_userparams.py b/Validation/RecoMuon/test/new_userparams.py index 9e82cc9f4973a..24815a2207f26 100644 --- a/Validation/RecoMuon/test/new_userparams.py +++ b/Validation/RecoMuon/test/new_userparams.py @@ -23,8 +23,8 @@ # + Location of the AFS place where to put the PDFs WebRepository = '/eos/user/c/cmsmupog/www/Validation/' -# User enabled to write in the afs area -User='giovanni' +# User enabled to write in the official repository +User='cprieels' # # Information about the new release @@ -34,28 +34,24 @@ Type='New', # Releases to compare - Release='CMSSW_10_1_0_pre1', + Release='CMSSW_10_5_0_pre2', # Conditions of the sample - # - # FullSim in CMSSW_10_1_0_pre1 - Condition='100X_upgrade2018_realistic_v10', - # - # FastSim in CMSSW_10_1_0_pre1 + Condition='105X_upgrade2018_realistic_v2', #Condition='100X_mcRun2_asymptotic_v2', # 'no' if no pileup, otherwise set BX spacing - PileUp='25ns', + PileUp='no', + #PileUp='25ns', #PileUp='', # for HeavyIons - #PileUp='no', Version='v1', Format='DQMIO', # If True use Fastsim, else use Fullsim + #FastSim=False, FastSim=False, - #FastSim=True, # for HeavyIons samples (few folders are not there) HeavyIons=False, @@ -91,7 +87,7 @@ # Type of parameters Type='Ref', - Release='CMSSW_10_0_0', + Release='CMSSW_10_5_0_pre1', # Conditions for Special RelVals in CMSSW_10_0_0 # @@ -100,8 +96,9 @@ #Condition='100X_upgrade2018_realistic_v6_mahiON', #standard RelVals (v1 and v2) # # FullSim PU25ns in CMSSW_10_0_0 - Condition='100X_upgrade2018_realistic_v6_muVal_resubwith4cores', + Condition='103X_upgrade2018_realistic_v8', # + # FastSim in CMSSW_10_0_0 #Condition='100X_mcRun2_asymptotic_v2_muVal', #Condition='100X_mcRun2_asymptotic_v2', #standard RelVals (v1) @@ -132,6 +129,7 @@ # For FullSim PU 25ns samples = ['RelValZMM_13', 'RelValTTbar_13'] +#samples = ['RelValTTbar_13'] # For HeavyIons FullSim #samples = ['RelValZEEMM_13_HI'] diff --git a/Validation/RecoTrack/python/plotting/html.py b/Validation/RecoTrack/python/plotting/html.py index 238e59eb2c4d4..6fe7a6c8875cd 100644 --- a/Validation/RecoTrack/python/plotting/html.py +++ b/Validation/RecoTrack/python/plotting/html.py @@ -418,6 +418,12 @@ def _formatPlotSets(self): ' ', ]) + if len(fileTable): + first_row = fileTable[0] + self._content.extend([ + ' Browse Folder' % (first_row[1][0:first_row[1].rfind('/')]) + ]) + def _appendColumnHeader(self, header): leg = "" if header in self._columnHeadersIndex: diff --git a/Validation/RecoTrack/python/plotting/plotting.py b/Validation/RecoTrack/python/plotting/plotting.py index 3e6979fb53a22..9277e5f98cf42 100644 --- a/Validation/RecoTrack/python/plotting/plotting.py +++ b/Validation/RecoTrack/python/plotting/plotting.py @@ -533,7 +533,7 @@ def _findBoundsY(th1s, ylog, ymin=None, ymax=None, coverage=None, coverageRange= ymin -- Minimum y value; if None, take the minimum of TH1s ymax -- Maximum y value; if None, take the maximum of TH1s coverage -- If set, use only values within the 'coverage' part around the median are used for min/max (useful for ratio) - coverageRange -- If coverage and this are set, use only the x axis specified by an (xmin,xmax) pair for the coverage + coverageRange -- If coverage and this are set, use only the x axis specified by an (xmin,xmax) pair for the coverage """ if coverage is not None or isinstance(th1s[0], ROOT.TH2): # the only use case for coverage for now is ratio, for which @@ -2532,6 +2532,7 @@ def create(self, tdirectoryNEvents, requireAllHistograms=False): def draw(self, *args, **kwargs): kargs = copy.copy(kwargs) kargs["ratio"] = False + kargs["separate"] = False return super(PlotOnSideGroup, self).draw(*args, **kargs) class PlotFolder: @@ -2672,7 +2673,7 @@ def limitSubFolder(self, limitOnlyTo, translatedDqmSubFolder): """Return True if this subfolder should be processed Arguments: - limitOnlyTo -- List/set/similar containing the translatedDqmSubFolder + limitOnlyTo -- List/set/similar containing the translatedDqmSubFolder translatedDqmSubFolder -- Return value of translateSubFolder """ return translatedDqmSubFolder in limitOnlyTo diff --git a/Validation/RecoTrack/python/plotting/validation.py b/Validation/RecoTrack/python/plotting/validation.py index d43477c69ab4f..9440431740a3b 100644 --- a/Validation/RecoTrack/python/plotting/validation.py +++ b/Validation/RecoTrack/python/plotting/validation.py @@ -5,6 +5,7 @@ import sys import shutil import subprocess +import urllib import ROOT ROOT.gROOT.SetBatch(True) @@ -735,7 +736,7 @@ def download(self): if not os.path.exists(certfile): print("Private key file {keyfile} does not exist, unable to download RelVal files from {url}".format(keyfile=keyfile, url=relvalUrl)) sys.exit(1) - + # curl --cert-type PEM --cert $HOME/.globus/usercert.pem --key $HOME/.globus/userkey.pem -k -O -O cmd = ["curl", "--cert-type", "PEM", "--cert", certfile, "--key", keyfile, "-k"] for u in urls: @@ -1293,5 +1294,13 @@ def _doPlots(self, plotterFolder, dqmSubFolder): print("Typically this is a naming problem in the plotter configuration") sys.exit(1) + if self._plotterDrawArgs.get("separate", False): + if not os.path.exists("%s/res"%newdir): + os.makedirs("%s/res"%newdir) + downloadables = ["index.php", "res/jquery-ui.js", "res/jquery.js", "res/style.css", "res/style.js", "res/theme.css"] + for d in downloadables: + if not os.path.exists("%s/%s" % (newdir,d)): + urllib.urlretrieve("https://raw.githubusercontent.com/musella/php-plots/master/%s"%d, "%s/%s"%(newdir,d)) + print("Created plots in %s" % newdir) return map(lambda n: n.replace(newdir, newsubdir), fileList) diff --git a/Validation/SiPixelPhase1RecHitsV/src/SiPixelPhase1RecHitsV.cc b/Validation/SiPixelPhase1RecHitsV/src/SiPixelPhase1RecHitsV.cc index b03dac31e51ed..c03a75f75d226 100644 --- a/Validation/SiPixelPhase1RecHitsV/src/SiPixelPhase1RecHitsV.cc +++ b/Validation/SiPixelPhase1RecHitsV/src/SiPixelPhase1RecHitsV.cc @@ -34,8 +34,6 @@ void SiPixelPhase1RecHitsV::analyze(const edm::Event& iEvent, const edm::EventSe auto id = DetId(it->detId()); for(SiPixelRecHit const& rechit : *it) { - SiPixelRecHit::ClusterRef const& clust = rechit.cluster(); - std::vector associateSimHit; associateSimHit = associate.associateHit(rechit); std::vector::const_iterator closestIt = associateSimHit.begin();