54 produces<ValueMap<DeDxData> >();
57 string estimatorName = iConfig.
getParameter<
string>(
"estimator");
71 MeVperADCPixel = iConfig.
getParameter<
double>(
"MeVperADCPixel");
72 MeVperADCStrip = iConfig.
getParameter<
double>(
"MeVperADCStrip");
75 useCalibration = iConfig.
getParameter<
bool>(
"UseCalibration");
76 m_calibrationPath = iConfig.
getParameter<
string>(
"calibrationPath");
78 if(!usePixel && !useStrip)
79 edm::LogWarning(
"DeDxHitsProducer") <<
"Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
91 if(MODsColl.size()!=0)
return;
97 vector<GeomDet*>
Det = tkGeom->dets();
98 for(
unsigned int i=0;
i<Det.size();
i++){
99 DetId Detid = Det[
i]->geographicalId();
104 double Thick=-1, Dist=-1, Norma=-1;
108 Norma = MeVperADCStrip/Thick;
109 }
else if(PixelDetUnit){
112 Norma = MeVperADCPixel/Thick;
121 MODsColl[MOD->
DetId] = MOD;
124 MakeCalibrationMap();
141 iEvent.
getByLabel(m_trajTrackAssociationTag, trajTrackAssociationHandle);
145 iEvent.
getByLabel(m_tracksTag,trackCollectionHandle);
147 size_t n = TrajToTrackMap.
size();
148 std::vector<DeDxData> dedxEstimate(n);
158 vector<DeDxTools::RawHits> hits;
161 const vector<TrajectoryMeasurement> & measurements = traj->measurements();
162 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
164 if( !trajState.
isValid())
continue;
168 double cosine = trackDirection.
z()/trackDirection.
mag();
170 if(
const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit)){
171 if(!useStrip)
continue;
181 mono.
detId= matchedHit->monoId();
182 stereo.
detId= matchedHit->stereoId();
187 if(!useStrip)
continue;
188 const SiStripRecHit2D* singleHit=&(projectedHit->originalHit());
194 mono.
detId= singleHit->geographicalId();
196 hits.push_back(mono);
197 }
else if(
const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
198 if(!useStrip)
continue;
204 mono.
detId= singleHit->geographicalId();
206 hits.push_back(mono);
207 }
else if(
const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
208 if(!useStrip)
continue;
214 mono.
detId= single1DHit->geographicalId();
216 hits.push_back(mono);
217 }
else if(
const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
218 if(!usePixel)
continue;
224 pixel.
charge = pixelHit->cluster()->charge();
226 pixel.
detId= pixelHit->geographicalId();
227 hits.push_back(pixel);
232 int NClusterSaturating = 0;
233 for(
size_t i=0;
i < hits.size();
i++)
238 dedxHits.push_back(
DeDxHit( charge, MOD->
Distance, pathLen, hits[
i].detId) );
240 if(hits[i].NSaturating>0)NClusterSaturating++;
243 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
244 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
248 val_and_error.second = NClusterSaturating;
250 dedxEstimate[
j] =
DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
252 filler.
insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
257 iEvent.
put(trackDeDxEstimateAssociation);
264 if(!useCalibration)
return;
266 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
267 t1->Add(m_calibrationPath.c_str());
269 unsigned int tree_DetId;
270 unsigned char tree_APVId;
273 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
274 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
275 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
279 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
280 t1->GetEntry(ientry);
282 MOD->
Gain = tree_Gain;
291 const uint32_t &
DetId)
294 const vector<uint8_t>& Ampls = Cluster->
amplitudes();
300 Saturating_Strips = 0;
301 for(
unsigned int i=0;
i<Ampls.size();
i++){
302 int CalibratedCharge = Ampls[
i];
307 CalibratedCharge = (int)(CalibratedCharge / MOD->
Gain );
308 if(CalibratedCharge>=1024){
309 CalibratedCharge = 255;
310 }
else if(CalibratedCharge>=255){
311 CalibratedCharge = 254;
315 toReturn+=CalibratedCharge;
316 if(CalibratedCharge>=254)Saturating_Strips++;
T getParameter(std::string const &) const
DeDxEstimatorProducer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
const_iterator end() const
last iterator over the map (read only)
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.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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 &)