54 produces<ValueMap<DeDxData> >();
57 string estimatorName = iConfig.
getParameter<
string>(
"estimator");
71 MeVperADCPixel = iConfig.
getParameter<
double>(
"MeVperADCPixel");
72 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";
92 if(MODsColl.size()!=0)
return;
98 vector<GeomDet*>
Det = tkGeom->dets();
99 for(
unsigned int i=0;
i<Det.size();
i++){
100 DetId Detid = Det[
i]->geographicalId();
105 double Thick=-1, Dist=-1, Norma=-1;
109 Norma = MeVperADCStrip/Thick;
110 }
else if(PixelDetUnit){
113 Norma = MeVperADCPixel/Thick;
122 MODsColl[MOD->
DetId] = MOD;
125 MakeCalibrationMap();
142 iEvent.
getByLabel(m_trajTrackAssociationTag, trajTrackAssociationHandle);
146 iEvent.
getByLabel(m_tracksTag,trackCollectionHandle);
148 size_t n = TrajToTrackMap.
size();
149 std::vector<DeDxData> dedxEstimate(n);
159 vector<DeDxTools::RawHits> hits;
162 const vector<TrajectoryMeasurement> & measurements = traj->measurements();
163 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
165 if( !trajState.
isValid())
continue;
169 double cosine = trackDirection.
z()/trackDirection.
mag();
172 if(!useStrip)
continue;
179 mono.
charge = getCharge((matchedHit->monoHit()->cluster()).
get(),mono.
NSaturating);
180 stereo.
charge = getCharge((matchedHit->stereoHit()->cluster()).
get(),stereo.
NSaturating);
182 mono.
detId= matchedHit->monoHit()->geographicalId();
183 stereo.
detId= matchedHit->stereoHit()->geographicalId();
185 hits.push_back(mono);
186 hits.push_back(stereo);
188 if(!useStrip)
continue;
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();
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();
214 hits.push_back(mono);
215 }
else if(
const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
216 if(!usePixel)
continue;
222 pixel.
charge = pixelHit->cluster()->charge();
224 pixel.
detId= pixelHit->geographicalId();
225 hits.push_back(pixel);
230 int NClusterSaturating = 0;
231 for(
size_t i=0;
i < hits.size();
i++)
236 dedxHits.push_back(
DeDxHit( charge, MOD->
Distance, pathLen, hits[
i].detId) );
238 if(hits[i].NSaturating>0)NClusterSaturating++;
241 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
242 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
246 val_and_error.second = NClusterSaturating;
248 dedxEstimate[
j] =
DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
250 filler.
insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
255 iEvent.
put(trackDeDxEstimateAssociation);
262 if(!useCalibration)
return;
264 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
265 t1->Add(m_calibrationPath.c_str());
267 unsigned int tree_DetId;
268 unsigned char tree_APVId;
271 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
272 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
273 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
277 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
278 t1->GetEntry(ientry);
280 MOD->
Gain = tree_Gain;
290 const vector<uint8_t>& Ampls = Cluster->
amplitudes();
296 Saturating_Strips = 0;
297 for(
unsigned int i=0;
i<Ampls.size();
i++){
298 int CalibratedCharge = Ampls[
i];
303 CalibratedCharge = (int)(CalibratedCharge / MOD->
Gain );
304 if(CalibratedCharge>=1024){
305 CalibratedCharge = 255;
306 }
else if(CalibratedCharge>=255){
307 CalibratedCharge = 254;
311 toReturn+=CalibratedCharge;
312 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
uint32_t geographicalId() const
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
const Surface::PositionType & position() const
The position (origin of the R.F.)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
int getCharge(const SiStripCluster *Cluster, int &Saturating_Strips)
virtual void beginRun(edm::Run &run, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void MakeCalibrationMap()
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
const Bounds & bounds() const
size_type size() const
map size
ClusterRef const & cluster() const
key_type key() const
Accessor for product key.
virtual void produce(edm::Event &, const edm::EventSetup &)
T const * product() const
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
const std::vector< uint8_t > & amplitudes() const