Skip to content

Commit

Permalink
Merge pull request #18021 from sandrofonseca/CTPPS_fastSim_910
Browse files Browse the repository at this point in the history
Integration of the CTPPS FastSim for CMSSW_9_1_X
  • Loading branch information
davidlange6 authored Apr 27, 2017
2 parents 8adaf87 + ec9d638 commit f0824ae
Show file tree
Hide file tree
Showing 35 changed files with 2,603 additions and 2 deletions.
8 changes: 8 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/GeometryVector"/>
<use name="DataFormats/Math"/>
<use name="root"/>

<export>
<lib name="1"/>
</export>
64 changes: 64 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef FastSimDataFormats_CTPPSFastSim_CTPPSFastRecHit_H
#define FastSimDataFormats_CTPPSFastSim_CTPPSFastRecHit_H

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/GeometryVector/interface/LocalPoint.h"

#include <vector>

class CTPPSFastRecHit {
public:
//destructor
// ~CTPPSFastRecHit() {}
CTPPSFastRecHit() : theDetUnitId(0) {}
// constructor
// requires the DetId, the hit position, the ToF and the CellId
// For the Tracker, ToF and CellId = 0
// For the timing x = x_CellId, y = y_CellId, z = z_detector

CTPPSFastRecHit(const Local3DPoint& entry, unsigned int detId, float tof, unsigned int cellId):
theEntryPoint( entry),
theDetUnitId( detId),
theTof(tof),
theCellId( cellId) {}
/// Entry point in the local Det frame
Local3DPoint entryPoint() const {return theEntryPoint;}

/* Time of flight in nanoseconds from the primary interaction
* to the entry point. Always positive in a PSimHit,
* but may become negative in a SimHit due to bunch assignment.
*/
float timeOfFlight() const {return tof();}

/// deprecated name for timeOfFlight()
float tof() const {return theTof;}

/* The DetUnit identifier, to be interpreted in the context of the
* detector system that produced the hit.
* For CTPPS its content has: Detector(CTPPS), SubDet (Tracker or Timing)
* ArmF(z>0)/ArmB(z<0), Pot and Plane (= 0)
*/
unsigned int detUnitId() const {return theDetUnitId;}
//the ToF cell number
unsigned int cellId() const {return theCellId;}

void setTof(float tof) {theTof=tof;}

void setLocal3DPoint(const Local3DPoint& entry){theEntryPoint = entry;}

void setDetUnitId(unsigned int detId){theDetUnitId = detId;}

void setCellId(unsigned int cellId){theCellId = cellId;}


protected:
// properties
Local3DPoint theEntryPoint; // position at entry
// association
unsigned int theDetUnitId;
float theTof; // Time Of Flight
unsigned int theCellId;
};


#endif //CTPPSFastRecHit_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef FastSimDataFormats_CTPPSFastSim_CTPPSFastRecHitContainer_H
#define FastSimDataFormats_CTPPSFastSim_CTPPSFastRecHitContainer_H

//FastSimDataFormats/CTPPSFastSim

#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/RefProd.h"
#include <vector>
#include "DataFormats/Common/interface/RefToBase.h"

namespace edm {
typedef std::vector<CTPPSFastRecHit> CTPPSFastRecHitContainer;
} // edm

#endif

99 changes: 99 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#ifndef FastSimDataFormats_CTPPSFastSim_CTPPSFastTrack_H
#define FastSimDataFormats_CTPPSFastSim_CTPPSFastTrack_H


#include "DataFormats/Math/interface/Vector.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Math/interface/Point3D.h"

#include <vector>
class CTPPSFastTrack {
public:
typedef math::XYZVector Vector;
typedef math::XYZPoint Point;
// ~CTPPSFastTrack() {}
CTPPSFastTrack() : thet(0.),thexi(0.),thecellid(0),thetof(0.),thex1(0.),they1(0.),thex2(0.),they2(0.),momentum_(0, 0, 0),vertex_(0, 0, 0) {}
// constructor
CTPPSFastTrack(float t,float xi,unsigned int cellid ,float tof,float x1,float y1,float x2,float y2,const Vector &momentum,const Point &vertex):
thet(t),
thexi(xi),
thecellid(cellid),
thetof(tof),
thex1(x1),
they1(y1),
thex2(x2),
they2(y2),
momentum_(momentum),
vertex_(vertex) {}

////////////////////////////
//
/// track momentum vector
const Vector &momentum() const;
/// Reference point on the track
const Point &referencePoint() const;
// reference point on the track. This method is DEPRECATED, please use referencePoint() instead
const Point &vertex() const ;
/* Time of flight in nanoseconds from the primary interaction
* to the entry point. Always positive in a PSimHit,
* but may become negative in a SimHit due to bunch assignment.
*/
float timeOfFlight() const {return tof();}

float t() const {return thet;}

float xi() const {return thexi;}

float tof() const {return thetof;}

float x1() const {return thex1;}

float y1() const {return they1;}

float x2() const {return thex2;}

float y2() const {return they2;}
float px() const {return momentum_.x();}
float py() const {return momentum_.Y();}
float pz() const {return momentum_.Z();}
float x0() const {return vertex_.x();}
float y0() const {return vertex_.Y();}
float z0() const {return vertex_.Z();}

unsigned int cellid() const {return thecellid;}

void setp(const Vector& momentum ) { momentum_ = momentum; }

void setvertex(const Point &vertex) {vertex_ = vertex;}

void settof(float tof) {thetof=tof;}

void sett(float t){thet = t;}

void setxi(float xi){thexi = xi;}

void setx1(float x1){thex1 = x1;}

void sety1(float y1){they1 = y1;}

void setx2(float x2){thex2 = x2;}

void sety2(float y2){they2 = y2;}

void setcellid(unsigned int cellid ){thecellid=cellid;}

private:
float thet;
float thexi;
unsigned int thecellid;
float thetof;
float thex1;
float they1;
float thex2;
float they2;
Vector momentum_;
Point vertex_;

};

#endif //CTPPSFastTrack_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef FastSimDataFormats_CTPPSFastSim_CTPPSFastTrackContainer_H
#define FastSimDataFormats_CTPPSFastSim_CTPPSFastTrackContainer_H

#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/RefProd.h"
#include <vector>
#include "DataFormats/Common/interface/RefToBase.h"

namespace edm {
typedef std::vector<CTPPSFastTrack> CTPPSFastTrackContainer;
} // edm

#endif

6 changes: 6 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/src/CTPPSFastRecHit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include <ostream>

std::ostream & operator<<(std::ostream & o, const CTPPSFastRecHit & hit)
{ return o << hit.detUnitId() << " " << hit.entryPoint() << " " << hit.tof() << " " << hit.cellId(); }

6 changes: 6 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/src/CTPPSFastTrack.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h"
#include <ostream>
//float t,float xi,unsigned int cellid ,float tof,const Vector &momentum,const Point &vertex)
std::ostream & operator<<(std::ostream & o, const CTPPSFastTrack & hit)
{ return o << hit.t() << " " << hit.xi() << " " << hit.cellid() << " " << hit.tof() ;}

28 changes: 28 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/src/classes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/***For CTPPS FastSim*/
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrackContainer.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHitContainer.h"
/***/


#include <vector>

namespace FastSimDataFormats_CTPPSFastSim {
struct dictionary {


//--- fastsim objects
CTPPSFastTrack xxxxt;
edm::CTPPSFastTrackContainer sxxxxt;
edm::Wrapper<edm::CTPPSFastTrackContainer> dummy1;
std::vector<const CTPPSFastTrack*> dummy2;

CTPPSFastRecHit xxxxr;
edm::CTPPSFastRecHitContainer sxxxxr;
edm::Wrapper<edm::CTPPSFastRecHitContainer> dummy3;
std::vector<const CTPPSFastRecHit*> dummy4;


};
}
16 changes: 16 additions & 0 deletions FastSimDataFormats/CTPPSFastSim/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<lcgdict>
<!-- fastsim objects -->
<class name="CTPPSFastTrack" ClassVersion="3">
<version ClassVersion="3" checksum="4107658808"/>
</class>
<class name="std::vector<CTPPSFastTrack>"/>
<class name="edm::Wrapper<std::vector<CTPPSFastTrack> > "/>
<class name="std::vector<const CTPPSFastTrack*>"/>

<class name="CTPPSFastRecHit" ClassVersion="3">
<version ClassVersion="3" checksum="2897018556"/>
</class>
<class name="std::vector<CTPPSFastRecHit>"/>
<class name="edm::Wrapper<std::vector<CTPPSFastRecHit> > "/>
<class name="std::vector<const CTPPSFastRecHit*>"/>
</lcgdict>
9 changes: 9 additions & 0 deletions FastSimulation/CTPPSFastGeometry/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="SimDataFormats/TrackingHit"/>
<use name="DataFormats/Common"/>
<use name="clhep"/>
<export>
<lib name="1"/>
</export>
65 changes: 65 additions & 0 deletions FastSimulation/CTPPSFastGeometry/interface/CTPPSToFDetector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef CTPPSToFDetector_h
#define CTPPSToFDetector_h
#include <vector>
#include <map>
#include <iterator>
#include <iostream>

class CTPPSToFDetector {
public:
CTPPSToFDetector(int ncellx,int ncelly, std::vector<double>& cellw,double cellh,double pitchx,double pitchy,double pos, int res);
CTPPSToFDetector(int ncellx,int ncelly, double cellw,double cellh,double pitchx,double pitchy,double pos, int res);
virtual ~CTPPSToFDetector() {};

double getHeight() {return detH_;};
double getWidth() {return detW_;};
double getPosition() {return detPosition_;};
int findCellId(double x, double y); // return the cell id corresponding to the given position
bool get_CellCenter(int cell_id, double& x, double& y); // return false if it failed
int get_CellId(int idx) {if (idx>=(int)theToFInfo.size()) return 0;
std::map<int,std::vector<double> >::const_iterator it=theToFInfo.begin();
std::advance(it,idx);
return it->first;
}
int get_CellMultiplicity() {return (int)theToFInfo.size();}; // return the number of cells with hit
int getMultiplicityByCell(int cellid) {if (!theToFInfo.count(cellid)) return 0;
return (int)theToFInfo.at(cellid).size();}; // return the hit multiplicity of the given cell

int get_nHits_() {return nHits_;}; // return the total hit multiplicity (full det)
std::vector<double> get_ToF(int cell) {if (!theToFInfo.count(cell)) return std::vector<double>();
return theToFInfo.at(cell);
}; // return the tof of the given cell
int getADC(int cell, int hit) {
if (!nADC_.count(cell)) return 0;
if ((int)nADC_.at(cell).size()<hit) return 0;
return nADC_.at(cell).at(hit);
}


void AddHit(double x, double y,double tof);
void clear() {detId_=0;nHits_=0;theToFInfo.clear();};
private:
int nCellX_;
int nCellY_;
double cellWq_; // width (X, horizontal dimension in mm)
std::vector<double> cellW_;//move to vector - diamond geometry
double cellH_; // height(Y, vertical dimension in mm)
double pitchX_; // distance (in X) between cells
double pitchY_; // distance (in Y) between cells
int fToFResolution_; // in ps
std::vector<std::pair<double,double> > cellColumn_; // lower and upper limits of cells in X
std::vector<std::pair<double,double> > cellRow_; // lower and upper limits of cells in Y
//
double detW_; // detector width
double detH_; // detector height
double detPosition_; // detector position from beam (absolute value)
//
int detId_;
int nHits_;
std::map<int,std::vector<int> > nADC_; // fake ADC counter: in case of multiple hits in the same cell,
// it counts the number of overlaps
std::map<int,std::vector<double> > theToFInfo;

typedef std::map<int,std::vector<double> > theToFInfo_t; // define a type for the tof info
};
#endif
25 changes: 25 additions & 0 deletions FastSimulation/CTPPSFastGeometry/interface/CTPPSTrkDetector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CTPPSTrkDetector_h
#define CTPPSTrkDetector_h
#include <vector>

class CTPPSTrkDetector {
public:
CTPPSTrkDetector(double detw, double deth, double detin);
virtual ~CTPPSTrkDetector() {};

public:
const double ppsDetectorWidth_;
const double ppsDetectorHeight_;
const double ppsDetectorPosition_;
std::vector<unsigned int> ppsDetId_;
int ppsNHits_;
std::vector<double> ppsX_;
std::vector<double> ppsY_;
std::vector<double> ppsZ_;
void clear() {ppsDetId_.clear();ppsNHits_=0;ppsX_.clear();ppsY_.clear();ppsZ_.clear();};
void AddHit(unsigned int detID,double x, double y, double z);
};

typedef std::pair<CTPPSTrkDetector,CTPPSTrkDetector> CTPPSTrkStation;

#endif
Loading

0 comments on commit f0824ae

Please sign in to comment.