53 produces<ValueMap<DeDxData> >();
56 string estimatorName = iConfig.
getParameter<
string>(
"estimator");
66 m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.
getParameter<
edm::InputTag>(
"trajectoryTrackAssociation"));
70 MeVperADCPixel = iConfig.
getParameter<
double>(
"MeVperADCPixel");
71 MeVperADCStrip = iConfig.
getParameter<
double>(
"MeVperADCStrip");
74 useCalibration = iConfig.
getParameter<
bool>(
"UseCalibration");
75 m_calibrationPath = iConfig.
getParameter<
string>(
"calibrationPath");
77 if(!usePixel && !useStrip)
78 edm::LogWarning(
"DeDxHitsProducer") <<
"Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
90 if(MODsColl.size()!=0)
return;
96 vector<GeomDet*>
Det = tkGeom->dets();
97 for(
unsigned int i=0;
i<Det.size();
i++){
98 DetId Detid = Det[
i]->geographicalId();
103 double Thick=-1, Dist=-1, Norma=-1;
107 Norma = MeVperADCStrip/Thick;
108 }
else if(PixelDetUnit){
111 Norma = MeVperADCPixel/Thick;
120 MODsColl[MOD->
DetId] = MOD;
123 MakeCalibrationMap();
140 iEvent.
getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
144 iEvent.
getByToken(m_tracksTag,trackCollectionHandle);
146 size_t n = TrajToTrackMap.
size();
147 std::vector<DeDxData> dedxEstimate(n);
157 vector<DeDxTools::RawHits> hits;
160 const vector<TrajectoryMeasurement> & measurements = traj->measurements();
161 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
163 if( !trajState.
isValid())
continue;
167 double cosine = trackDirection.
z()/trackDirection.
mag();
169 if(
const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit)){
170 if(!useStrip)
continue;
180 mono.
detId= matchedHit->monoId();
181 stereo.
detId= matchedHit->stereoId();
186 if(!useStrip)
continue;
187 const SiStripRecHit2D* singleHit=&(projectedHit->originalHit());
193 mono.
detId= singleHit->geographicalId();
195 hits.push_back(mono);
196 }
else if(
const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
197 if(!useStrip)
continue;
203 mono.
detId= singleHit->geographicalId();
205 hits.push_back(mono);
206 }
else if(
const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
207 if(!useStrip)
continue;
213 mono.
detId= single1DHit->geographicalId();
215 hits.push_back(mono);
216 }
else if(
const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
217 if(!usePixel)
continue;
223 pixel.
charge = pixelHit->cluster()->charge();
225 pixel.
detId= pixelHit->geographicalId();
226 hits.push_back(pixel);
231 int NClusterSaturating = 0;
232 for(
size_t i=0;
i < hits.size();
i++)
237 dedxHits.push_back(
DeDxHit( charge, MOD->
Distance, pathLen, hits[
i].detId) );
239 if(hits[i].NSaturating>0)NClusterSaturating++;
242 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
243 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
247 val_and_error.second = NClusterSaturating;
249 dedxEstimate[
j] =
DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
251 filler.
insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
256 iEvent.
put(trackDeDxEstimateAssociation);
263 if(!useCalibration)
return;
265 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
266 t1->Add(m_calibrationPath.c_str());
268 unsigned int tree_DetId;
269 unsigned char tree_APVId;
272 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
273 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
274 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
278 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
279 t1->GetEntry(ientry);
281 MOD->
Gain = tree_Gain;
290 const uint32_t &
DetId)
293 const vector<uint8_t>& Ampls = Cluster->
amplitudes();
299 Saturating_Strips = 0;
300 for(
unsigned int i=0;
i<Ampls.size();
i++){
301 int CalibratedCharge = Ampls[
i];
306 CalibratedCharge = (int)(CalibratedCharge / MOD->
Gain );
307 if(CalibratedCharge>=1024){
308 CalibratedCharge = 255;
309 }
else if(CalibratedCharge>=255){
310 CalibratedCharge = 254;
314 toReturn+=CalibratedCharge;
315 if(CalibratedCharge>=254)Saturating_Strips++;
T getParameter(std::string const &) const
DeDxEstimatorProducer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
LocalVector localDirection() const
void insert(const H &h, I begin, I end)
std::vector< DeDxHit > DeDxHitCollection
const Bounds & bounds() const
const Plane & surface() const
The nominal surface of the GeomDet.
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
virtual void beginRun(edm::Run const &run, const edm::EventSetup &) override
const Surface::PositionType & position() const
The position (origin of the R.F.)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Abs< T >::type abs(const T &t)
void MakeCalibrationMap()
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
size_type size() const
map size
key_type key() const
Accessor for product key.
T const * product() const
virtual void produce(edm::Event &, const edm::EventSetup &) override
const_iterator begin() const
first iterator over the map (read only)
const std::vector< uint8_t > & amplitudes() const
int getCharge(const SiStripCluster *Cluster, int &Saturating_Strips, const uint32_t &)